Trying to create and write to file using NSFileHandle... and it doesn't seem to be working
cocoa-touch, iphone
Solution
I need to create the file first:
[[NSFileManager defaultManager] createFileAtPath:self.gpsFilePath contents:nil attributes:nil];
Problem
What am I doing wrong here: ``` NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; self.gpsFilePath = [documentsDirectory stringByAppendingString: @"/gpsReadings.txt"]; self.gpsFile = [NSFileHandle fileHandleForWritingAtPath:self.gpsFilePath]; [self.gpsFile writeData:@"GPS Readings"]; [self.gpsFile closeFile]; ```