Problem with saveToFile
Posted
by zp26
on Stack Overflow
See other posts from Stack Overflow
or by zp26
Published on 2010-05-29T08:38:16Z
Indexed on
2010/05/29
8:42 UTC
Read the original article
Hit count: 356
Hi, I have a problem with a NSData writeToFile. I have implemented the code below but i have an anomaly. When i run my program on the simulator, the new file is created and the informations are stored; when i build the app in my device , the file isn't created. The debug don't give me any error but don/t save anything. Can you help me? Thanks so much and sorry for my english.
-(void)saveXML:(NSString*)name:(float)x:(float)y:(float)z{
NSMutableData *data = [NSMutableData data];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver setOutputFormat:NSPropertyListXMLFormat_v1_0];
[archiver encodeFloat:x forKey:@"x"];
[archiver encodeFloat:y forKey:@"y"];
[archiver encodeFloat:z forKey:@"z"];
[archiver encodeObject:name forKey:@"name"];
[archiver finishEncoding];
BOOL result = [data writeToFile:@"XML Position" atomically:YES];
if(result)
[self updateTextView:@"success"];
[archiver release];
}
© Stack Overflow or respective owner