@protocol VideoDelegate <NSObject>
@optional
-(void)videoPlayBackDidFinish:(NSObject*)currencyInfo;
-(void)videoPlayBackDidStart;
我想发送一个带有videoPlayBackDidFinish
的json对象,这样我就可以收到它完成的通知,我可以选择使用该对象的部分
例如:object.valueOfWhatever
答案 0 :(得分:0)
将JSON转换为字典,然后将其作为userInfo发送到通知中:
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];
}