Question

I have created a group folder in my Xcode project named USER_PHOTO

Screenshot of folder in groups list

Then I store some images into that folder.

Screenshot of image files in the folder

In my application, I open the camera mode.

How can I save the captured images into the "USER_PHOTO" folder? Also, how can I read all images from the folder?

Please give me ideas to solve these issues. Thanks in advance.

Was it helpful?

Solution

It can be done in the following way,

NSString *animationFolderName = UIDeviceOrientationIsPortrait(mDeviceOrientation)? @"Portrait_animation":@"Landscape_animation";
    int index = 0;
    NSMutableArray *imagesArray = [[NSMutableArray alloc] init];
    for (index = 1; index <= kMaxAnimationImages; index++) 
    {
        NSString *cname = [animationFolderName stringByAppendingFormat:@"/%d.png", index];
        UIImage *img = [UIImage imageNamed:cname];
        if (img) 
            [imagesArray addObject:img];
    }

OTHER TIPS

I think you have a misconception there. The groups and folders you make in Xcode do not appear in your app when running on the iOS device. You can see what happens by finding the built app in the Simulator's folders (under ~/Library/Application Support/iPhone Simulator/" and look into its app package. You'll see that all your file are in there in one big folder. This is different from Mac app, where you have several folders for Resources, code, etc.).

So, to read the images, you simply read them from your app's folder. Use NSBundle pathForResource:ofType: to get to them. The "resource" path in iOS is identical to your app's folder.

Also, on iOS, your app can then only write to a few folders next to its .app package, e.g. "Documents". You can see that in the Simulator folders as well.

The NSBundle class offers functions to get you the paths to these folders.

You can then also set up your app (thru a plist key) to have the Documents folder visible in iTunes so that you can then copy the stored files to your Mac/PC via iTunes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top