dataRepresentationOfType replacement?


#1

Will you answer questions from the 2nd edition of the book (that’s all I have)?

I have been dutifully working through this excellent book for a week now and am thrilled with how well it is teaching me Cocoa. I hit a stumbling block today working on RaiseMan.

dataRepresentationOfType has been deprecated in 10.4 and I am using a 10.6 machine. Can you offer the preferred way to do this? Is the answer available in the 3rd edition?

Thanks,
David


#2

[quote=“dmknuth”]Will you answer questions from the 2nd edition of the book (that’s all I have)?

I have been dutifully working through this excellent book for a week now and am thrilled with how well it is teaching me Cocoa. I hit a stumbling block today working on RaiseMan.

dataRepresentationOfType has been deprecated in 10.4 and I am using a 10.6 machine. Can you offer the preferred way to do this? Is the answer available in the 3rd edition?

Thanks,
David[/quote]

developer.apple.com/mac/library/ … edAPI.html says: “Use dataOfType:error: instead.” and this is what I have in MyDocument.m:

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
    // End editing
    [[tableView window] endEditingFor:nil];
        
    // Create an NSData object from the employees array
    return [NSKeyedArchiver archivedDataWithRootObject:employees];
    // ignore the error argument because there will be no errors
}

I’m not quite sure this is what you want and chapter 10 is quite long (and sadly, I don’t have the second edition anymore as I donated it to my university’s library last year), so feel free to ask again

PS: you know that you can download all the examples from the book at bignerdranch.com/solutions/Cocoa-3rd.tgz ?