• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: writeToFile and arrayWithContentsOfFile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: writeToFile and arrayWithContentsOfFile
      • From: Bryan Blackburn <email@hidden>
References: 
 >Custom bundle extension (From: Mark Levin <email@hidden>)
 >writeToFile and arrayWithContentsOfFile (From: Chuck Rice <email@hidden>)
 >Re: writeToFile and arrayWithContentsOfFile (From: Bryan Blackburn <email@hidden>)

  • Prev by Date: Re: Apple and Cocoa (why don't they eat their own dog food?)
  • Next by Date: Atomic operations in Obj-C?
  • Previous by thread: Re: writeToFile and arrayWithContentsOfFile
  • Next by thread: Re: writeToFile and arrayWithContentsOfFile
  • Index(es):
    • Date
    • Thread