Posts

Showing posts from February, 2017

Implementing delegates in Swift

Image
So, what are delegates? …in software development, there are general reusable solution architectures that help to solve commonly occurring problems within a given context, these “templates”, so to speak, are best known as design patterns. Delegates are a design pattern that allows one object to send messages to another object when a specific event happens. Imagine an object A calls an object B to perform an action. Once the action is complete, object A should know that B has completed the task and take necessary action, this can be achieved with the help of delegates!      For a better explanation, I am going to show you how to create a custom delegate that passes data between classes, with Swift in a simple application, start by downloading or cloning this   starter project   and run it! You can see an app with two classes, ViewController A and ViewController B. B has two views that on tap changes the background color of the ViewController, ...

Our Favorite Xcode Shortcuts

Image
1. Edit all in scope: CTRL+⌘+E This shortcut allows you to change the name of a variable or function and have that change take effect in your entire file. Here is an illustration: Before After We simply clicked on `label` within the `set` method, typed ⌘+CTRL+E, and changed the name to `titleLabel`. 2. Fix all in scope: CTRL+⌥+⌘+F This one is a handful, but it’s super handy. It will allow Xcode to automatically fix all errors that can be fixed automatically. 3. Open quickly: ⇧+⌘+O Type ⇧+⌘+o and start typing in the search box that opens. The strength of “open quickly” is that the search engine is able to discern which files or functions you’re looking for even if you only enter parts of the name. For example, typing “appfinish” will bring up “applicationDidFinishLaunching” as part of the results. 4. Searching within a file: CTRL+6 This powerful shortcut opens the jump bar so you can see all existing symbols in the open ...