Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIViewController IBOutlets are nil

I have an UIViewController class with two labels and a UIImageView set as IBOutlets, and I have this outlets connected in my xib, I have double checked they are connected properly, however when I check the their value in the debugger they are 0x0 so I cant change them programatically. Any ideas on what I might be doing wrong.

Heres the header file of my code:

#import <UIKit/UIKit.h>


@interface PlateDetailViewController : UIViewController {

     IBOutlet UIImageView *image;
     IBOutlet UILabel *price;
     IBOutlet UILabel *description;

}

@property (nonatomic, retain)IBOutlet UIImageView *image;

@property (nonatomic, retain)IBOutlet UILabel *price;

@property (nonatomic, retain)IBOutlet UILabel *description;


@end
like image 284
Mauricio Galindo Avatar asked Oct 23 '10 20:10

Mauricio Galindo


1 Answers

Your outlets won't get set until the view controller's view is actually instantiated, which in your case is probably happening shortly after initWithNibName:bundle:—at which point they'll still be nil. Any setup you do that involves those outlets should be happening in your view controller's -viewDidLoad method.

like image 80
Noah Witherspoon Avatar answered Nov 22 '22 19:11

Noah Witherspoon