dimanche 27 avril 2014

objective c - impossible d'écrire sur le fichier plist après le déploiement sur iPhone - Stack Overflow


Dear all. I am facing a problem. I can read and write on plist while working on simulator of xcode. but when I deploy the app in iPhone, i can't write on plists.


I have created a sample project having 2 button on it. By one button, I can display the text from plist. By second button, I try to write on that plist. But the writing doesn't happen. The app doesn't crash while clicking on the second button. I can't understand the problem in my code.


/*code is given below*/
-(void)writePlist:(NSString *)fname withArray:(NSMutableArray *) myArray
{
NSString * path = nil;
path = [(NSString *) [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:fname];
[myArray writeToFile:path atomically:NO];
}



It could be that myArray variable contains non-serializable object values (probably custom objects or something like that).




Does the directory you are trying to write to exist? You may want to verify its existence (and create it if it isn't already there) before trying to write a file into it.



Dear all. I am facing a problem. I can read and write on plist while working on simulator of xcode. but when I deploy the app in iPhone, i can't write on plists.


I have created a sample project having 2 button on it. By one button, I can display the text from plist. By second button, I try to write on that plist. But the writing doesn't happen. The app doesn't crash while clicking on the second button. I can't understand the problem in my code.


/*code is given below*/
-(void)writePlist:(NSString *)fname withArray:(NSMutableArray *) myArray
{
NSString * path = nil;
path = [(NSString *) [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:fname];
[myArray writeToFile:path atomically:NO];
}


It could be that myArray variable contains non-serializable object values (probably custom objects or something like that).



Does the directory you are trying to write to exist? You may want to verify its existence (and create it if it isn't already there) before trying to write a file into it.


Related Posts:

0 commentaires:

Enregistrer un commentaire