Page 463 - Watch for Autocomplete


Autocomplete can be your friend, but not when it gives you something that doesn’t match what the book is looking for. At the top of Page 463 you add a new method

+ (UIViewController *)viewControllerWithRestorationIdentifierPath:(NSArray *)path coder:(NSCoder *)coder { BOOL isNew = NO; if ([path count] == 3){ isNew = YES; } return [[self alloc] initForNewItem:isNew]; }

Note, however, that Autocomplete provides the first argument’s variable name as “identifierComponents” and not “path”, which is used in the If-Then check. If you leave the method name as autocomplete provides it you will get an Error from the precompiler “Use of undeclared identifier ‘path’”

Just change the variable name in the method title and all is well…


Mark H


As an alternative: Instead of modifying the function header, one could just simply use the correct identifierComponents name instead of path in the code block, and let autocomplete complete the name as you type…