Go back

Top 10 iOS Dev Tips

9m 43s

Top 10 iOS Dev Tips

The video presents 10 practical iOS coding tips to enhance the development experience in Xcode. First, it highlights keyboard shortcuts: Command + Backslash toggles breakpoints at the cursor, and Command + Y activates or deactivates all breakpoints, useful during compilation. For debugging, the `dump()` method is recommended over `print()` to reveal an object's internal property values, though it avoids computed properties due to potential side effects. To maintain code quality, Xcode's built-in spell checker can be enabled to flag typos. Navigation is improved with Option + Arrow keys for word jumps and Control + Arrow keys for camel case segments, with Shift for selection. For troubleshooting, wtflayout.com deciphers complex Auto Layout constraint errors, simplifying conflict resolution. Additionally, closure syntax.com assists with Swift closure declarations (e.g., parameters, return types, `in` keyword), while blocks syntax.com offers similar help for Objective-C blocks. Date formatting is simplified via dateformatter.com, which clarifies patterns like MMM for month names and yyyy for years. The final tip encourages subscribing to the Inside iOS Dev YouTube channel and enabling notifications to catch future episodes. Overall, these tips aim to boost productivity, reduce debugging time, and improve code accuracy.

Transcription

1489 Words, 7841 Characters

English
Leave a like, comment and subscribe and hit that notification bell icon, it helps to promote the show. Hey guys, today we have 10 iOS coding tips for you for a better development experience. Number one, typically you would enable your breakpoints by just clicking on the line of code where you want the breakpoint and to disable them you would either drag them away like this or right click and delete the breakpoint. But there is a hand your keyboard shortcut that you can use, it's command backwards slash and it will where your cursor is placed, that's the line of code when you tap command slash, that's where it will be enabled. So you can enable or disable or add or remove your breakpoints using that shortcut. Number two, there is a way to activate or deactivate your debug mode for Xcode to stop at the breakpoints you have in setting your code base with this button over here, activate or deactivate breakpoints and there is a command, there is also a menu option in the debug menu for it as well. But you could also use a keyboard shortcut for this, it's command Y and it will do exactly the same thing, you see it enables or disables the breakpoints in your code. So if you hit command R and run your code and you realize you don't want the breakpoints, you can quickly disable it while it's still compiling. Number three, often when you're debugging your code base and need to print out an object that you have and you would like to know and examine the internal properties and variables that it has, quite often you'll get, if you print the object, you'll get actually just the name of the class of that object and you'll have to either somehow print individual properties or if they're inaccessible private properties, you'll have to actually like break point and debug and examine it that way. So there is a trick in iOS that you can do instead. What you can do is to use this dump method instead of print. As you can see, this dump method prints out the, again, the name of the class that we had, but also any values stored internally in its properties. But notice it does not print out the full name, which is a computed property and a computed property is really a method, right, just with a syntactic sugar of looking at like a property. So this computation might have side effects and then the dump method does not run those, nor does it run any methods. Number four, so guys sometimes happens that we misspell some words in our project while writing some code, although it's not a big deal that we have some typos in our code because our code will run logically fine. It will not be shown to the end users, but to maintain code based over the time, we should make sure that our code don't have many typos X code has provided a tool called spell checker. So what you can do is you can go to edit and then go to format and then spelling in grammar and then check this option, check spelling while typing. For example, I want to make a method name called something, okay, so let's try to declare a method name called something, okay, and I will intentionally miss one alphabet. So see, the X code has highlighted this that I have missed something here and I know what I missed. And now it's fine. Number five, here are two handy keyboard shortcuts for you to travel and navigate your code easier. One of them is option and left or right arrow, this allows you to travel between beginning or end of the word or jump to the next or previous word. And then if you have a very long method name or property name, long word and camel cased word in your project and your code, you can also travel between the cases, camel cases of the camel cased word with control, left or right arrow. And both of those work equally with selecting. So if you hold option shift and then arrow keys, it will select or deselect in the direction you're going from the beginning and end to the end of the word or vice versa. And then same goes for the camel case traveling. If you hold control shift and then the direction, it will highlight or un-highlight that part of the camel case word. Number six, sometimes in our projector, we get some error logs from Xcode that the project is unable to satisfy some constraints when we are using auto layout. But these constraints are hard to decipher, right? So we need a way to decipher them, right? So there is a handy tool for that. There is a website called wtflayout.com where you can just copy paste your error logs from the auto layout and then click on the go button. And when you click on the go button, it will do some calculations regarding what Xcode is trying to teach you about the constraints. So it says that the name labels height should be equal to 25, right? And the name labels height should also be at least 50. So now we can see that these two statements are conflicting. And this was the reason that Xcode was complaining about the constraints. So the solution is simple now. We just need to remove one of these constraints and our problem will be fixed. Number seven. Okay, guys. So now I want to declare closure. I want to take an int parameter, but I want to return a string, let me figure it out. How to do that, is it? No, wish I could have some handy tool for this as well. Okay, we had. So we have this website, closure syntax.com. So here it actually shows you how to do that. How you can declare a variable, how to declare an optional variable type, alias, constant, everything related to closure. Let me use the sky. Okay, so this guy is telling me to use like this, okay, to use the parameter types inside this and then declare the return type like this. Okay. So here I go. I will declare the parameter type inside this places. And then here and I will write equal to, okay, and, okay. So this is done, but I'm still getting one error, okay. So let me jump on to the implementation part. Here I can see, I need to use an in keyword, okay, where I'm in and since I want to return something. So I will return string, finally it worked thanks to this website. By the way, if you don't want to use this domain, you can use this domain as well to reach out to this site, cost on closure syntax.com number eight, one more thing. If you wonder about how to use that same thing in objective C. So in objective C, we have blocks, right? So we have a website with a similar domain blocking blocks syntax.com. And you can just reach out to this website and it will provide you a handy list of all the options to declare a variable or as a property or as a method parameter, everything about blocks in objective C. Number nine, quite often when you work with data for matters, I don't know how about you guys, but I do forget the four matters syntax like what is the actual, this is the day, right? And then is this the months, a singular months or is it the double M for triple M to display the full month's name, I never remembered. So if you also find yourself not try and not to be able to memorize this pattern and the syntax for date form matter, there's a handy website that you could use as called an as date form matter.com. And we'll allow you to first play with your form matter with your text, right? And put different variables here and also gives you the examples of how you can format things. So if I would like to have the full months, I need the triple M for it or the full year, they're four wise. Then for my use case, I probably want to have this four amps over here. And then for the day, I'd like to have the date and then the name of the day, or the name of the week of that day. Number 10. The last tip we have for you guys for today is to subscribe to Inside iOS dev YouTube channel, click subscribe button and hit that notification bell so that you never miss the next episode. Subscribe and hit that notification button so you never miss the next episode.

Podcast Summary

Key Points:

  1. Use Command + Backslash to quickly add or remove breakpoints at the cursor.
  2. Use Command + Y to toggle all breakpoints on or off, even during compilation.
  3. Use the `dump()` method instead of `print()` to inspect an object's internal properties and values, though it skips computed properties and methods.
  4. Enable Xcode's spell checker (Edit > Format > Spelling and Grammar > Check Spelling While Typing) to catch typos in code.
  5. Use Option + Arrow keys to navigate between words, and Control + Arrow keys to navigate between camel case segments; add Shift to select.
  6. Use wtflayout.com to decipher and resolve confusing Auto Layout constraint error logs.
  7. Use closure syntax.com to quickly look up correct closure syntax (e.g., parameter types, return types, `in` keyword).
  8. Use blocks syntax.com for Objective-C block syntax references.
  9. Use dateformatter.com to easily determine correct date format patterns (e.g., MMM for month names, yyyy for year). 1
  10. Subscribe to the Inside iOS Dev YouTube channel and hit the notification bell to stay updated.

Summary:

The video presents 10 practical iOS coding tips to enhance the development experience in Xcode. First, it highlights keyboard shortcuts: Command + Backslash toggles breakpoints at the cursor, and Command + Y activates or deactivates all breakpoints, useful during compilation. For debugging, the `dump()` method is recommended over `print()` to reveal an object's internal property values, though it avoids computed properties due to potential side effects.

To maintain code quality, Xcode's built-in spell checker can be enabled to flag typos. Navigation is improved with Option + Arrow keys for word jumps and Control + Arrow keys for camel case segments, with Shift for selection. com deciphers complex Auto Layout constraint errors, simplifying conflict resolution.

com offers similar help for Objective-C blocks. com, which clarifies patterns like MMM for month names and yyyy for years. The final tip encourages subscribing to the Inside iOS Dev YouTube channel and enabling notifications to catch future episodes.

Overall, these tips aim to boost productivity, reduce debugging time, and improve code accuracy.

FAQs

You can use Command + Slash (/) to add or remove a breakpoint at the line where your cursor is placed.

Use the keyboard shortcut Command + Y to activate or deactivate all breakpoints. This is useful when you want to run your code without stopping at breakpoints.

Unlike print(), the dump() method prints the internal properties and values of an object, not just its class name. However, it does not execute computed properties or methods, as these may have side effects.

Go to Edit > Format > Spelling and Grammar, then check 'Check Spelling While Typing'. This will highlight misspelled words in your code, helping you maintain a clean codebase.

Use Option + Left/Right arrow to jump between words, and Control + Left/Right arrow to move between camel case parts. Hold Shift with these to select text, e.g., Option + Shift + Arrow or Control + Shift + Arrow.

Visit wtflayout.com, paste your Auto Layout error logs, and click 'Go'. The site analyzes the constraints and identifies conflicts, such as two conflicting height requirements, making it easier to resolve the issue.

Chat with AI

Loading...

Pro features

Go deeper with this episode

Unlock creator-grade tools that turn any transcript into show notes and subtitle files.