• 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: Bryan Blackburn <email@hidden>
  • Date: Wed, 15 Jan 2003 01:25:34 -0700
  • Mail-followup-to: email@hidden

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];

Bryan


On Jan 14, 2003 22:03, Chuck Rice stated:
> I am attempting to write an array to a file, then read it back in.
> This seems to work the first time, but if I write, then read, then
> write, it fails. I am a bit new at this, so I do not understand the
> error I am getting. By logging the array, it looks like it writes it
> out and reads it back in correctly. What am I missing. There is a
> truncated portion of the Console Log following the code frag. -Chuck-
>
[snip]
>
> - (IBAction)ReadBackup:(id)sender
> {
> PhoneBookData = [NSMutableArray
> arrayWithContentsOfFile:[@"~/PhoneBackup.txt
> "stringByStandardizingPath]];
> NSLog(@"\r%@",PhoneBookData);
> }
>
[el snippo]
_______________________________________________
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: Chuck Rice <email@hidden>
References: 
 >Custom bundle extension (From: Mark Levin <email@hidden>)
 >writeToFile and arrayWithContentsOfFile (From: Chuck Rice <email@hidden>)

  • Prev by Date: Re: Apple and Cocoa (why don't they eat their own dog food?)
  • Next by Date: Re: positioning items in a drawer
  • Previous by thread: Re: writeToFile and arrayWithContentsOfFile
  • Next by thread: Re: writeToFile and arrayWithContentsOfFile
  • Index(es):
    • Date
    • Thread