开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜