This talk covers a handful of code patterns that were successful on my recent projects. Some of these patterns include Block Safety, "Tell, Don't Ask", Using DataSources for your network-based *Service objects.
DEFAULT BLOCK - (void)processPhoneList:(NSArray *)list completion: (PhoneListCompletionHandler)incomingCompletion { PhoneListCompletionHandler completion = (incomingCompletionHandler != NULL) ? incomingCompletionHandler : ^{ NSLog(@"processPhoneList: did complete"); }; // When the time comes, look ma' no need to check for nil! completion() }
NEW IN XCODE 6.31 // as long as the type is a simple object or block pointer. - (nullable AAPLListItem *)itemWithName:(nonnull NSString *)name; - (NSInteger)indexOfItem:(nonnull AAPLListItem *)item; 1 https://developer.apple.com/swift/blog/?id=25
The core idea of the Tell, Don't Ask pattern is that any *ViewController or *Service or *Store you build should, when initialized or otherwise "prepared", have all the information it needs to do its job. It should not ask the global state for information. -- Mike Zornek, right now