我有一个带有 userInfo 的 aNotification 我想用另一种格式调用另一种方法。有没有办法从 [aNotification userInfo] 中检索字符串并修改它?userInfo 的格式如下: { action = "the string I'd like to use"; 我确实喜欢这个(而且它几乎可以工作),但我觉得有更好的方法来做同样的事情。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playClicked:) name:kNotificationActionTapped object:nil];
..................
-(void)playClicked:(NSNotification *)aNotification {
NSLog(@"Notification=%@", [aNotification userInfo]);
SBJsonWriter *jsonWriter = [[SBJsonWriter alloc] init];
NSString *jsonString = [jsonWriter stringWithObject:[aNotification userInfo]];
[jsonWriter release];
NSString * string1 = [jsonString substringFromIndex:11];
NSString * string2 = [string1 substringToIndex:[watch length] -2];
NSLog(@"string=%@", string1);
NSLog(@"string=%@", string2);
}