Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void) writeToFile: (NSString *) targetString
- {
- //_loggingString holds the data, which keeps on accumulating as the user performs operations. At some point of time (callbacks from API's I call this method, to actually, write this string in the file and clear this string afterwards.)
- NSString *oldString = [_loggingString copy];
- _loggingString = [oldString stringByAppendingString:targetString];
- if (![[NSFileManager defaultManager]fileExistsAtPath:@"somePath"])
- {
- [[NSFileManager defaultManager]createFileAtPath:@"somePath" contents:nil attributes:nil];
- }
- NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:@"somePath"];
- [fileHandle seekToEndOfFile];
- [fileHandle writeData:[_loggingString dataUsingEncoding:NSUTF8StringEncoding]];
- _loggingString = @"";
- }
Add Comment
Please, Sign In to add comment