我建議創建一個名爲FacebookSingletonDelegate
@class FacebookSingleton;
@protocol FacebookSingletonDelegate <NSObject>
- (void) facebookSingletonDidLogin:(FacebookSingleton *) facebookSingleton;
- (void) facebookSingletonDidNotLogin:(FacebookSingleton *) facebookSingleton;
- (void) facebookSingletonDidLogout:(FacebookSingleton *) facebookSingleton;
- (void) facebookSingleton:(FacebookSingleton *)facebookSingleton
request:(FBRequest *) request
didLoad:(id)result;
@end
協議,然後在你的FacebookSingleton.h創建屬性像
@property (nonatomic, strong) id<FacebookSingletonDelegate> delegate;
然後讓你的視圖控制器符合協議 -
@interface MyViewController<FacebookSingletonDelegate>
然後,將自己設置爲視圖中的委託c ontroller,防爆 -
myViewController.delegate = self;
然後,觸發從FacebookSingleton實現(FacebookSingleton.m)的委託方法 -
- (void)request:(FBRequest *)request didLoad:(id)result
{
[self.delegate facebookSingleton:self request:request didLoad:result];
}
然後,你可以實現你的視圖控制器內部下面的方法 -
- (void) facebookSingleton:(FacebookSingleton *)facebookSingleton
request:(FBRequest *) request
didLoad:(id)result
{
// the view controller will receive the event in here
}
來源
2012-09-12 22:08:13
Das