Errata


#1

Errata for Chapter 28: Your First Cocoa Application will appear in this post.

b[/b] The correct method implementations for -dataOfType:error: and -readFromData:ofType:error: should be as follows:

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
    if (!todoItems) {
        todoItems = [NSMutableArray array];
    }
    
    NSData *data = [NSPropertyListSerialization dataWithPropertyList:todoItems 
                                                              format:NSPropertyListXMLFormat_v1_0 
                                                             options:0 //Was NSPropertyListMutableContainers when printed
                                                               error];
    return data;
}

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
{
    todoItems = [NSPropertyListSerialization propertyListWithData:data 
                                                          options:NSPropertyListMutableContainers //Was 0 when printed
                                                           format:NULL 
                                                            error];
    return (todoItems != nil);
}

#2

Guys:

I feel like a wise guy, but I don’t mean to be. The errata, however, needs an errata. The book lists “todoItems”, the errata lists “toDoItems”.

I am learning a lot from this great book.
Thanks,
– Bob Ayres


#3

Ha! Good eye! I’ve fixed the above post accordingly.


#4

IS it possible to make posts like this a ‘sticky post’?