• 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: NSArray saveToFile: atomically does not work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray saveToFile: atomically does not work


  • Subject: Re: NSArray saveToFile: atomically does not work
  • From: Shawn Erickson <email@hidden>
  • Date: Tue, 4 Jan 2005 09:12:58 -0800


On Jan 4, 2005, at 8:56 AM, Bruce Truax wrote:

I have an NSMutableArray *variableArray.  This array is made of of
ACVariable objects defined as follows:

@interface ACVariable : NSObject {

[snip]

When I try to save this array using writeToFile: atomically: as in the code
snippet below it always fails.


    if([variableArray writeToFile:@"/Users/bruce/Desktop/variables"
                       atomically:YES]){
        NSLog(@"Variable File saved successfully");
    }else{
        NSLog(@"Unable to save variable file");
    }


According to the documentation for writeToFile: atomically: for this to work
all of the receiver's contents must be property list objects, and I thought
that NSNumber and NSStrings were both property list objects (at least if you
go into the Propery list editor, you can add children which are numbers and
strings). The documentation then parenthetically lists NSString, NSData,
NSArray and NSDictionary as the allowable objects. Is it really true that
you cannot use writeToFile: atomically if you have anything other than these
four types of objects in your array?

It only works if the objects in the array itself are one of the ones listed in the documentation. In this case you have your own object in the array. It is inconsequential that your object happens store strings internally.


In Cocoa you can only store NSNumbers, NSStrings, NSDictionary and NSData object to files... just kidding ;-)

Review the following conceptual documentation to understand the various ways to go about what you want...

<http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/ index.html#//apple_ref/doc/uid/10000047i>

-Shawn

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSArray saveToFile: atomically does not work
      • From: Bruce Truax <email@hidden>
References: 
 >NSArray saveToFile: atomically does not work (From: Bruce Truax <email@hidden>)

  • Prev by Date: Re: NSArray saveToFile: atomically does not work
  • Next by Date: Re: statically linking one of my framework to a foundation tool
  • Previous by thread: Re: NSArray saveToFile: atomically does not work
  • Next by thread: Re: NSArray saveToFile: atomically does not work
  • Index(es):
    • Date
    • Thread