the*_*wan 7 cocoa objective-c nsdictionary nsstring
我有一个问题,NSDictionary返回null一个NSString即使字符串是字典中.这是代码:
- (void)sourceDidChange:(NSNotification *)aNote {
NSDictionary *aDict = [aNote userInfo];
DLog(@"%@", aDict);
NSString *newSourceString = [aDict objectForKey:@"newSource"];
DLog(@"%@", newSourceString);
newSourceString = [newSourceString stringByReplacingOccurrencesOfString:@" " withString:@""];
DLog(@"%@", newSourceString);
NSString *inspectorString = [newSourceString stringByAppendingString:@"InspectorController"];
DLog(@"%@", inspectorString);
newSourceString = [newSourceString stringByAppendingString:@"ViewController"];
DLog(@"%@", newSourceString);
}
Run Code Online (Sandbox Code Playgroud)
我得到以下日志声明:
2010-04-17 23:50:13.913 CoreDataUISandbox[13417:a0f] -[RightViewController sourceDidChange:] { newSource = "Second View"; }
2010-04-17 23:50:13.914 CoreDataUISandbox[13417:a0f] -[RightViewController sourceDidChange:] (null)
2010-04-17 23:50:13.916 CoreDataUISandbox[13417:a0f] -[RightViewController sourceDidChange:] (null)
2010-04-17 23:50:13.917 CoreDataUISandbox[13417:a0f] -[RightViewController sourceDidChange:] (null)
2010-04-17 23:50:13.917 CoreDataUISandbox[13417:a0f] -[RightViewController sourceDidChange:] (null)
Run Code Online (Sandbox Code Playgroud)
如你所见,字符串在键下的字典中newSource,但是当我打电话时objectForKey:,我得到了null.我甚至尝试过清理项目的后备选项.
有没有人碰到这个,或者我只是忘记了一些非常基本的东西?
| 归档时间: |
|
| 查看次数: |
5496 次 |
| 最近记录: |