views:

446

answers:

3

I've seen many questions asked about how to add images to the simulator and have seen two answers: - Click and hold to save in Mobile Safari on the phone - Add the files to the 100Apple (or whatever) folder Both worked great in everything previous to iOS SDK 4.0. Those same methods no longer work for me, and neither for anyone else that I have seen.

I have tried to write an image to the photo library manually using the following chuck of code I found somewhere

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
UIAlertView *alert;

// Unable to save the image  
if (error)
    alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                                       message:@"Unable to save image to Photo Album." 
                                      delegate:self cancelButtonTitle:@"Ok" 
                             otherButtonTitles:nil];
else // All is well
    alert = [[UIAlertView alloc] initWithTitle:@"Success" 
                                       message:@"Image saved to Photo Album." 
                                      delegate:self cancelButtonTitle:@"Ok" 
                             otherButtonTitles:nil];
[alert show];
[alert release];
}

But it errors every time. So is it a problem with the write access of the simulator? or just some bug? I have already updated to the iOS 4.1 SDK in hopes of it being fixed, but it isn't.

A: 

If it's any consolation, you're not the only one having problems with OS4 programming. I'm just trying to learn the language myself (I've done object-oriented programming before, but not for iPhone) and would you believe that Apple's own 'Hello World' tutorial crashes too? I've checked and re-checked it, no errors. No idea what's going wrong with it as I'm new to all platform-specific commands and libraries.

-Ash

Ash
Unfortunately, a lot of Apple's sample code has issues. However, their documentation is usually very helpful...
jtbandes
A: 

This question is spot-on. All the current advice I've seen about dragging/dropping to Safari, creating DCIM\100APPLE, etc, are all ineffective in SDK 4.

Philip Su
+2  A: 

I am using Xcode 3.2.4 with SDK 3.2, 4.0.1 and 4.1. The following steps worked for me: 1. Launch simulator 2. Drag an image from Finder to the simulator which will always launch Safari to show the image 3. CLICK and HOLD that click for a couple of seconds, then you will see a popup with a "Save Image" button

Somehow it has started working, I guess they fixed it. Your method works, as well as just browsing to an image in Safari and click+holding to save it. Thanks.
alunsford3