NSArray saveToFile: atomically does not work
NSArray saveToFile: atomically does not work
- Subject: NSArray saveToFile: atomically does not work
- From: Bruce Truax <email@hidden>
- Date: Tue, 04 Jan 2005 11:56:27 -0500
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