to pare locations down to a selected range. For this, we’ll use NSPredicates and sort descriptors - one of the more powerful Foundation API’s. But first we need to make a new model - an MSRange model - that will allow us to easily move ranges around the app.
reference to our original locations datasource. Being reference types you can’t just assign copiedDataSource = dataSource. Anything that happens to copiedDataSource will affect dataSource and vice versa because they share the same pointer. In order to copy objects entirely, with a new chunk of memory and a new pointer, we must use NSCopying. The object being copied must conform to the NSCopying protocol. Under the hood, copyWIthZone: is called on the object being copied.
into UITableView with reusable cells, animated index paths, and delegates for all standard actions. Let’s use the moveRowAtIndexPath: and canMoveRowAtIndexPath: delegate methods to allow the user to reorder the set of location types. A little-used but powerful feature.
methods like cellForRowAtIndexPath or didSelectRowAtIndexPath Our settings view controller acts as a delegate for the cells being reordered. Certain events (like the reordering of cells) trigger these methods to be called. The view controller implements them
and UITableViewCell. No importing of third-party libraries and no having to write hundreds of lines of code if you were writing this app in the C you wrote in CS50.
objects: 1) We keep a mental model of the object across maps and tables. 2) We’re passing a 64 bit pointer around instead of a potentially huge chunk of memory. 3) The object is easily extendable.. What are other things we can do with our objects?
different files import MSSingleton and MSLocation. Too much boilerplate! Create a ‘pch’ file that will be linked to every file in the project. You must do the following additional compiler setup..
CS50 IDE, Instruments takes Valgrind to another level There are the standard tools for profiling memory leaks and threading bugs but also tools for: • graphics usage • speed tests for Core Data fetches • a busy network layer • zombie objects • UI automated interactions (finger tapping, swiping, long-press) Much more
favorite Instruments features - Color Blended Layers Color blended layers only works with a device. 1. Hold down the play button and choose ‘profile’ 2. Instruments will start up, choose Core Animation 3. On the right-hand side panel, choose ‘Display Settings’ 4. Check ‘color blended layers’ The phone should now look like this:
that are not blended. Views in red are blended views where the graphics processor blends the view’s CALayer. Here, we see that our main and sublabels are opaque while the label property of our detail and delete buttons are blended.
for our two buttons and walk the property path setting the button label’s opaque property to YES. The button’s color will now be black unless you set it so do that too. Profile the App’s Core Graphics processing one more time:
is having to do much less work. If this table were to have enough rows where scrolling reached 60 frames per second, changing the opacity of the buttons could really benefit the performance of our app.
strings have been wrapped in an NSLocalizedString() function. The operating system will match the argument passed in with a key that you must provide. The keys are located in a .strings file that you must create. There is a .strings file for each language supported by the operating system.
those from indie devs, support English, Spanish, German, French, Portuguese, and Italian. These languages cover the majority of iOS users using the Latin alphabet. Localizing Asian languages is much more difficult from both a translation and user interface standpoint.
‘step in’ and ‘step over’ functionality seen in the CS50 IDE. Besides the standard features, you can: • Setup a breakpoint to make a sound when it’s triggered. • Setup a breakpoint to send an email when it’s triggered. • Setup a breakpoint to be ignored unless a variable is true or method returns true.
We could put the method in a global constants file but that’s overkill for large projects that are only going to use the method once albeit disparagingly. Objective-C categories provide a powerful way to extend the functionality of Foundation and UIKit classes.
as web or server-side devs mainly because the front end compiler does static analysis for you. But there were a few other reasons that are no longer true: One screen size - now we have several. One language - now we have two. No legacy - 2007 is getting smaller in the rear-view mirror. Over time gigantic, aging codebases have come into being.
create in order to conveniently store two floats? Have you ever wanted something that’s easy to copy and not referenced like a struct but smart and powerful like an object? Do you get tired of header and implementation files and feel a bit like you’re coding during the Reagan administration?
tuple instead. Swift has much more powerful structs and enums which would’ve simplified your CS50 assignments. Swift accelerates the extinction of the header files in our industry. Apps built in modern languages have far fewer files with far fewer lines of code. Despite code snippets and thorough knowledge XCode shortcuts, my wrist hurts ;(
runtime and therefore may change and be recompiled. .a (static library) - linked at compile time and therefore doesn’t change during the runtime because the object code that makes up the binary is set.
with header files and documentation. Useful when you have a suite of apps under one banner. Gmail, Google Docs, Google Maps, etc. all probably share a framework.
years of Apple elevating user interaction and user experience to the highest priority. Notice that MapStack uses Apple defaults whenever possible i.e. no third parties and few custom objects. You should dig a little to discover the amazing controls available to you at project creation. We didn’t make our map, rows, or buttons too small. In fact, many views have a minimum size that cannot be overridden without some serious hacks.
webservice. Great for debugging web traffic. Paw - Build your http requests with different environments, auth tokens. Sketch - Adobe Illustrator replacement that’s geared toward Apple, costs about an order of magnitude less and weighs even less than that. Paintcode - Generates code for the shapes you draw on the GUI. Bezier path heaven. 3rd party tools