#Key Notes from Hidden iOS 7 Development Gems
##Xcode
###Method completion (class implementation)
Type the first few characters of a method, without the return type to get the list of method signatures. This is awesome, because only the methods that make sense for this class implemetation will be listed!
####Except, with IBAction methods
For IBAaction methods, start typing the first few characters of (IBAction)selector...
###Edit in scope In the menus, there's an option called Edit All In Scope. Allows visualisation of all occurrences of a variable or method name that occur within the scope in which it is defined. Also, allows live edit of the variable name, only within its appropriate scope, with visualisation of the change as it occurs. Very cool!
Don't have to use find and replace.
###Debug quick looks Starting in Xcode 5.1 Beta
Implement - (id)debugQuickLookObject { ... } to return practically whatever you want for an object that you want to show quick look information during debugging.
###Rename IB objects
In the outline view, selecting an IB object in the IB hierarchy/outline and waiting for a couple of seconds lets you change IB object names. Does not change the underlying object names. Just for reference. Works like finder.
###Source control Searching revision history.
This performs a binary search through revision history. Saves a ton of time.
Use git bisect start!
git bisect bad < defaults to HEAD
git bisect good < set the last known good
Git will automagically find the midpoint. Run tests, look at code, etc. And so forth. Binary search to the point where the bug originated. Pretty freaking neat.
##iOS simulator ###Double high status bar For example, when in a call, the status bar changes height.
In response, the content needs to adjust accordingly.
Use Hardware > Toggle In-Call Status Bar menu item to show that in the simulator. Then act accordingly.
In code, we may detect this with UIApplicationWillChangeStatusBarFrameNotification and UIApplicationDidChangeStatusBarFrameNotification.
UIApplicationDelegate has callbacks for this
###Color blended layers Turn this on to quickly identify views that use transparency for no good reason whatsoever.
This is common with UITableView controls. Backgrounds are transparent by default. Set them to opaque, for an easy performance win. Also, images with an alpha channel force iOS to render their container view with transparency. Changing that will require replacing the image with one that does not contain an alpha channel.
##Instruments ###Call trees Very cool. Lets us look at performance of methods in the app vs total resource usage.
Shows in terms of absolute time and percentage of total time.
- Check Invert Call Tree to see methods taking the longest time
- Check Hide System Libraries to reduce noise
###CPU strategy views
Can help optimize hardware usage
####Concurrent object enumeration! For example: Use both cores for concurrent object enumeration
// Use NSEnumerationConcurrent for multi-core enumeration
// This uses grand central dispatch
// Really freaking cool
// atomic updates
NSArray *myObjects = ...;
[myObjects enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(...)] {
// do something with object
}];
##API ###URL and path utilities
Categories for manipulating paths
Use these instead of manually manipulating URLs or string paths!
NSURL.h and NSPathUtilities.h
####NSURLComponents is a new class
- Useful for constructing URLs in favor of constructing URL strings. Very neat.
- Also useful for modifying existing URLs!