2013-03-15 22 views
0
@protocol VideoDelegate <NSObject> 

@optional 
-(void)videoPlayBackDidFinish:(NSObject*)currencyInfo; 
-(void)videoPlayBackDidStart; 

我想送與videoPlayBackDidFinish JSON對象,所以我會接受它完成的通知,我可以任選該對象的使用部位我如何在協議委託方法得到的通知和對象發送一個對象來操作

例如:object.valueOfWhatever

+0

我不同意正在關閉的問題!我確切地知道他在問什麼,以及如何回答他是否需要添加「我可以」而不是「我想要」? – badweasel 2013-03-16 09:48:32

回答

0

轉換的JSON的字典,然後在該通知將其作爲用戶信息:

NSDictionary *quickDict = [NSDictionary dictionaryWithObjectsAndKeys:object1, key1, nil]; 

NSNotification* notification = [NSNotification notificationWithName:kVideoDidFinishNotification object:self userInfo:quickDict]; 
[[NSNotificationCenter defaultCenter] postNotification:notification]; 

我不知道如何使videoPlayBackDidFinish是消息的接收器,而無需在委託做這樣的事情:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish:) name:kVideoDidFinishNotification object:nil]; 

,然後在方法獲取到字典:

-(void)videoPlayBackDidFinish: (NSNotification*)notification 
{ 
    NSDictionary *jsonInfo = [notification userInfo]; 
} 
+0

非常感謝,我現在要試試這個! – 2013-03-15 15:23:48

相關問題