2013-03-15 21 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

相关问题