0
@protocol VideoDelegate <NSObject>

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

我想用 发送一个 json 对象,videoPlayBackDidFinish这样我就可以收到它已完成的通知,并且我可以选择使用该对象的一部分

前任:object.valueOfWhatever

4

1 回答 1

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];
}
于 2013-03-15T15:22:21.723 回答