Do you ever get stuck on something, and then when you work out what you were doing wrong you feel a bit foolish?
I was just thinking – it would be much more convenient if there was a keyboard shortcut to block comment some code. I know that with the keyboard shortcut Command-/ you can automatically generate single line comments:
But what I was after was a keyboard shortcut to generate block comments. Strangely this capability seems to be missing from Xcode, but I happened upon an Xcode Source Editor extension called BlockComment that seemed to do the job.
So – after installing BlockComment, I went into the Key Bindings tab in Xcode preferences, double clicked on the BlockComment binding to add a keyboard shortcut, and… nothing.
I closed Xcode, opened Xcode – did it again and… nothing. I’ve done this before, how strange! Read up on key bindings, hmm… yes I seem to be doing the right thing, what could be going wrong?
Then I watched a video and that was when I felt foolish.
Of course! You can’t just click anywhere on the line – you need to click in the key field on the right!
Sometimes when you work out what you were doing wrong, it all seems so obvious!
So! Things I’ve learned today
FIRST – When customizing a keyboard shortcut in Key bindings – click in the Key field!
SECOND – BlockComment – works quite well, I recommend!
THIRD – sometimes there’s no substitute for a video tutorial!
You might think that’s a strange sentiment for a book author, but as it turns out I’m currently working on a video course to accompany the book!
Of course, everyone has a preference for how to learn. Maybe you like books coz you can read them on the train. Maybe you prefer videos as you find it easier to learn visually. Either way, you have a choice now when learning iOS development with Swift.
Or – you can check out the livevideo course “iOS Development with Swift in Motion” here. The video course is currently in the Manning early access program, and new Units will be put out regularly.
You can use both together or independently, depending on your preference!
Good luck with them, and enjoy block commenting your code with keyboard shortcuts!