Reputation: 133
I want to write an application for IOS. The application should take images and stores with these images the name of the image along with some information about the gyroscope and maybe also the accelerometer from the mobile phone.
I hope to store these information in to a textfile, or something like that. Because I want to read these information from a different application and need these information to every image.
So the question is, how can I write information into a file from a running mobile application? I have no idea where to search for something like this.
Upvotes: 0
Views: 50
Reputation: 130
You can convert image in base64 string and append all information with "comma separated" string as CSV file do.
ImageName.png,OtherInformation,BASE64IMAGESTRING
Convert final string in to NSData and writeToFile.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"yourfilename.dat"];
// Save it into file system
[data writeToFile:dataPath atomically:YES];
Upvotes: 1