У меня есть переменнаяКак перенести сильную переменную id в переменную UIImage?
@property (strong, nonatomic) id dataObject;
Это указатель на UIImage
. Я хочу отправить его в новую переменную.
@property (nonatomic, retain) UIImage *theImage;
Когда я пытаюсь сделать это, приложение падает с этой ошибкой: unrecognized selector sent to instance 0x68423b0
Как отправить его в моей новой переменной? Заранее спасибо.
contentViewController.h:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "pageAppViewController.h"
@class pageAppViewController;
@interface ViewController : UIViewController
{
NSArray *content;
UIImageView *theImageView;
UIImage *theImage;
}
@property (strong, nonatomic) IBOutlet UIImageView *theImageView;
@property (strong, nonatomic) id dataObject;
@property (nonatomic, retain) UIImage *theImage;
@end
contentViewController.m:
#import "ViewController.h"
#import "pageAppViewController.h"
@implementation ViewController
@synthesize theImageView, dataObject;
@synthesize theImage;
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//this is the line that is causing the problems.
theImage = dataObject;
theImageView = [[UIImageView alloc] initWithImage: theImage];
[self.view addSubview:theImageView];
}
@end
попробуйте это theImage = (UIImage *) dataObject; – IPaPa
Спасибо, но это не сработало. – ctw