bmueller
bmueller

Reputation: 2711

Pass UIImage from one class to another

I'm using this tutorial for capturing images with AVFoundation. I'm trying to get the captured image from CaptureSessionManager (an NSObject class) back to the AROverlayViewController. How do I go about doing this?

I tried putting @property (nonatomic, retain) UIImage *finalImage; in AROverlayViewController.h, then setting arController.finalImage = image; in CaptureSessionManager.m, but the log is saying that finalImage is null.

Any thoughts on how best to do this? Thanks!

Upvotes: 0

Views: 360

Answers (3)

DLende
DLende

Reputation: 5242

There is a property on the class CaptureManager

@property (nonatomic, retain) UIImage *stillImage;

which you can get by this code

UIImage *final = [captureManager stillImage];

Upvotes: 2

Hariprasad.J
Hariprasad.J

Reputation: 307

NSData *imageData;

- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
        [self performSelectorInBackground:@selector(showLoading) withObject:nil];

        UIImage *capturedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
       imageData = [[NSData alloc]init]; 
       imageData = UIImagePNGRepresentation(capturedImage);
       [imageData retain];

       [reader dismissModalViewControllerAnimated: YES];

}

You can pass this NSData to other view you can acces this image.

Upvotes: 0

bmueller
bmueller

Reputation: 2711

I finally got it - add UIImage *test = [captureManager stillImage]; in AROverlayViewController.m. God, that took me forever.

Upvotes: 0

Related Questions