References are null after synthesizing
I've got a problem with this code.
@class CatalogMenu;
@class SettingsMenu;
@interface TabBar : UIViewController {
CatalogMenu *catalogMasterView;
SettingsMenu *settingsMasterView;
}
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) IBOutlet CatalogMenu *catalogMasterView;
@property (nonatomic, retain) IBOutlet SettingsMenu *settingsMasterView;
I got a UIViewController subclass, which implements the interface at the top. To use my classes in this UIViewController i've imported the two classes CatalogMenu and SettingsMenu. The problem is, that all the variables are null after 开发者_StackOverflow中文版synthesizing. That means, that they all got no address in the memory. The problem disappears if i change the subclass to NSObject. But this can't be the answer, because then i cant use the UIViewController functions. Is this a known problem?
Synthesizing doesn't actually allocate your variables which is why they are null, it just provides the Getter/Setter methods for accessing the variables. In your init method in the TabBar class you need to allocate your catalogMasterView and settingsMasterView
精彩评论