I just started programming in objective-c and I have a problem with “use of undeclared identifier ‘uneImage’; did you mean ‘_uneImage’?”. Lot of post speak about this but I haven’t found the solution.
.h :
#import
@interface ViewController : UIViewController
{
UIImagePickerController *picker;
}
@property (weak, nonatomic) IBOutlet UIImageView *uneImage;
- (IBAction)album:(id)sender;
@end
.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)album:(id)sender
{
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
uneImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
When you define a property
xyz, by default its name is transformed to_xyzto name its backing variable. You can override it with@synthesize name;or even@synthesize name = someOtherName;, but the use of@synthesizeis no longer required.The property itself is visible from the outside, but it does not introduce an unqualified name in the scope the same way the variables do. In other words, you cannot use the property without prefixing it with
self, but you can use its backing variable.To make the long story short, replace
with
or
to make it work.