Xcode Version 4.3.2 and 10.7 SDK


#1

To start out …

  • (BOOL)autosavesInPlace
    {
    return YES; [color=#FF0000]<------- change this to NO until things get working[/color]
    }
  • (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError [color=#FF0000]<------- implement this before testing[/color]
    {
    if (!itemArray) {
    itemArray = [NSMutableArray array];
    }
    NSData *data = [NSPropertyListSerialization dataWithPropertyList:itemArray
    format:NSPropertyListXMLFormat_v1_0
    options:NSPropertyListMutableContainers
    error];
    return data;
    }

  • (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError [color=#FF0000]<------- implement this before testing[/color]
    {
    NSString *error;
    NSPropertyListFormat format;
    itemArray = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainers format:&format errorDescription:&error];
    if (itemArray) {
    return YES;
    } else {
    return NO;
    }
    }

NOTE: I used [color=#0040FF]itemArray[/color] instead of [color=#008080]todoItems[/color]. My Bad!


#2

+ (BOOL)autosavesInPlace
– Was this method automatically included by default for you in Xcode? We do not implement this method, as we want the default implementation, which returns NO. I don’t happen to have the very first printing of the book with me, and I honestly can’t remember if we implemented it initially. At any rate, it has since been removed.

[b]- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError

  • (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError[/b]
    – We prefer to break up long implementation chunks for the reader, as too much typing without testing can cause problems for new programmers. Even if not all of the desired functionality is present, or certain behavior can lead to a crash, we (at a minimum) want to reassure the reader that everything that they’ve typed so far will compile and run.

Thank you for your feedback, as it does force us to think about our exercises from additional perspectives~

~Mikey


#3

Old message, but for those who follow later, +(BOOL)autosavesInPlace is indeed part of the template now, at least in the configuration I have (Mountain Lion 10.8.2 and Xcode 4.5.1). I’ve found the book to be quite remarkably compatible with this version.