Re: NSArray saveToFile: atomically does not work
Re: NSArray saveToFile: atomically does not work
- Subject: Re: NSArray saveToFile: atomically does not work
- From: Guy English <email@hidden>
- Date: Tue, 4 Jan 2005 12:12:05 -0500
While all your members are Property list objects ACVariable itself
isn't. You may want an - (NSString*) description method on ACVariable
that returns a dictionary you can save to a property list. Then
you'll want an initWithDictionary: method to re-create your ACVariable
from the dictionary.
On Tue, 04 Jan 2005 11:56:27 -0500, Bruce Truax <email@hidden> wrote:
> I have an NSMutableArray *variableArray. This array is made of of
> ACVariable objects defined as follows:
>
> @interface ACVariable : NSObject {
> NSString *variable;
> NSNumber *all;
> NSNumber *surface;
> NSString *lowLimit;
> NSString *highLimit;
> NSString *weight;
> NSString *derivativeIncrement;
>
> }
>
> + (NSArray *)variableList;
> - (NSString *)variable;
> - (void)setVariable:(NSString *)aVariable;
> - (NSNumber *)all;
> - (void)setAll:(NSNumber *)anAll;
> - (NSNumber *)surface;
> - (void)setSurface:(NSNumber *)aSurface;
> - (NSString *)lowLimit;
> - (void)setLowLimit:(NSString *)aLowLimit;
> - (NSString *)highLimit;
> - (void)setHighLimit:(NSString *)aHighLimit;
> - (NSString *)weight;
> - (void)setWeight:(NSString *)aWeight;
> - (NSString *)derivativeIncrement;
> - (void)setDerivativeIncrement:(NSString *)aDerivativeIncrement;
>
> @end
>
> 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?
>
> Bruce
>
> _______________________________________________
> 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
>
_______________________________________________
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