Re: writeToFile and arrayWithContentsOfFile
Re: writeToFile and arrayWithContentsOfFile
- Subject: Re: writeToFile and arrayWithContentsOfFile
- From: Chuck Rice <email@hidden>
- Date: Wed, 15 Jan 2003 00:46:44 -0800
arrayWithContentsOfFile: returns an autoreleased object, so if you need to
use the results later (which I'm guessing you are since you're loading
it into an object variable), you'll need to retain it:
PhoneBookData = [[NSMutableArray
arrayWithContentsOfFile:[@"~/PhoneBackup.txt
"stringByStandardizingPath]] retain];
That was it! Thanks. Looking at the doc:
arrayWithContentsOfFile:
+ (id)arrayWithContentsOfFile:(NSString *)aPath
Creates and returns an array containing the contents of the file
specified by aPath. The file identified by aPath must contain a
string representation produced by the writeToFile:atomically:
method. In addition, the array representation must contain only
property list objects (NSString, NSData, NSArray, or NSDictionary
objects).
Returns nil if the file can't be opened or if the contents of the
file can't be parsed into an array.
See Also: - writeToFile:atomically:
How do I know that it is an autoreleased object? Am I looking at the
wrong doc? -Chuck-
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.