pointer to view in "view based application"
hi I created a "view based application " and I have three classes: -MyAppViewController; -Item (UIView subclass); -MySingleton;
I need to call from item class, a method of MyAppViewController so I need to create a pointer, but the problem is that I do not understand when you create the link:
in singleton:
开发者_JS百科h
@class MyAppViewController;
...
@interface MySingleton : NSObject {
id plCall;
...
}
...
@property (nonatomic, retain) id plCall; //and @synthesize in .m
...
the item:
[[MySingleton sharedMySingleton].plCall myMethod];
but I miss the connection to the controller that should be so:
[MySingleton sharedMySingleton].plCall = MyAppViewController;
but this does not happen because it is a "view based application " and never i allocated directly the view
thanks a lot
If you get your controller object created by xib, you can do this in your controller's -viewDidLoad
@implementation MyAppViewController
...
- (void)viewDidLoad{
[MySingleton sharedMySingleton].plCall = self;
}
...
@end
精彩评论