Note that there are some explanatory texts on larger screens.

plurals
  1. POactions after dismissModalViewControllerAnimated
    primarykey
    data
    text
    <p>After I select a photo with the camera I'm saving it as <code>NSData</code>. This takes a while and I dont want my users to wait for it. I want it to happen at the background. My question is whether it is wise to perform methods after I call "<code>dismissModalViewControllerAnimated:NO</code>".</p> <p>this is my code, which outputs the following:</p> <p>debug1<br> debug2<br> debug4<br> debug5<br> debug6<br> debug3</p> <pre><code>- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // Access the uncropped image from info dictionary UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; NSLog(@"debug1"); // Save image in the normal photo album UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); NSLog(@"debug2"); [[MySingleton sharedSingleton] addImg:image]; NSLog(@"debug3"); [picker dismissModalViewControllerAnimated:NO]; [_delegate startStep2]; } -(void) addImg: (UIImage *) img { NSLog(@"debug4"); NSData *jpegData = UIImageJPEGRepresentation([img rotateAndScaleFromCameraWithMaxSize:1500.0], 0.9f); NSLog(@"debug5"); image = [[NSData alloc] initWithData:jpegData]; NSLog(@"debug6"); } </code></pre> <p>Can I dismiss the viewcontroller first and than do other stuff, or isnt that a good way?</p> <p>edit// I did solve the waiting problem by doing this:</p> <pre><code>[[MySingleton sharedSingleton] performSelectorInBackground:@selector(addImg:) withObject:image]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload