the following is my source code:
/–‘fileName’ is an available filePath.–/
NSLog(@"%@", @"v-log start");
NSMutableArray *txtArray = [[NSMutableArray alloc] init];
[txtArray addObject:@"test"];
[txtArray writeToFile:fileName atomically:YES];
NSLog(@"%@", @"v-log end");
those code can be run perfectly if I put them in the (void)viewDidLoad
but I get ‘FilesHandling[3294:c07] * -[NSPathStore2 getFileSystemRepresentation:maxLength:]: message sent to deallocated instance 0x7146ad0′ Exception when I put them in (IBAction)btnClicked:(id)sender.
Can you please tell me why ??
Probably because the fileName string has been deallocated. Did you retain it?