Welcome, Guest. Please login or register.
Did you miss your activation email?
April 30, 2017, 03:35:50 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Chapter Study
| | |-+  Chapter 19 - Archiving
| | | |-+  Possible mistake on page 435?
Pages: [1]   Go Down
Author Topic: Possible mistake on page 435?  (Read 1700 times)
Posts: 3

« on: December 14, 2010, 11:02:03 AM »

First page of Chapter 19:
If your objects are of type NSString, NSDictionary, NSArray, NSDate, NSData, or NSNumber, you can use the writeToFile:atomically:encoding:error method implemented in these classes to write your data to a file.

I'm not finding the writeToFile:atomically:encoding:error method listed in the Apple docs for NSNumber or NSDate, even in the listing of deprecated methods. Is this a mistake in the textbook?

Would the following be a valid alternative?

Code: (Objective-C)
id plist = [NSPropertyListSerialization dataFromPropertyList:myNSNumberOrNSDataObject format:NSPropertyListXMLFormat_v1_0 errorDescription:nil];

[plist writeToFile:@"plist" atomically:YES encoding:NSUTF8Encoding error:nil];
Hero Member
Posts: 3114

« Reply #1 on: December 17, 2010, 01:30:59 PM »

Apple has been fuzzy on this.  You CAN archive an array containing NSNumber objects, for example, even though the documentation doesn't state that.  It used to.  So I will point that out in the next edition.



Steve Kochan
Posts: 3

« Reply #2 on: December 19, 2010, 02:28:00 PM »

Hi Steve, you're right, Apple seems more than fuzzy on this - the NSArray writeToFile:atomically: docs say "If the array’s contents are all property list objects (NSString, NSData, NSArray, or NSDictionary objects)...", and the Property List Programming Guide says: "You can create a property list in Objective-C if all of the objects in the aggregate derive from the NSDictionary, NSArray, NSString, NSDate, NSData, or NSNumber class." I guess this is a mistake in the Apple docs, one way or the other.
Pages: [1]   Go Up
Jump to:  

Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.