简体   繁体   中英

how to find a file that was created programmatically directly from my iphone

I've created an image file in an application and stored it in the fileDirectory using the following code:

NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
UIImage* videoImage = [self resizeImage:[UIImage imageWithData:self.videoImageData] toWidth:width andHeight:height];
NSData *imageData2 = UIImageJPEGRepresentation(videoImage, imageQuality);
[imageData2 writeToFile:[basePath stringByAppendingPathComponent:@"myfile.png"] atomically:YES];

now from my iPhone device how can i find and open this file?

You would need to connect your iPhone to a Mac to see it. iExplorer does the trick.

imageData2 writeToFile:[basePath stringByAppendingPathComponent:@"/myfile.png"] atomically:YES];

你错过了反斜线

In Xcode you can go to Window -> Organizer and select the Devices tab.

Under the device in the panel on the left you will see Applications . Select your application to see the file system for the app sandbox. Select Download to save all the data to the mac (as a package file).

You can right-click a package file to browse as a folder by selecting Show Package Contents from the context menu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM