Ios5 NSMutableDictionary iVar初始化失败
试图从临时本地NSMutableDictionary(tmpDict)填充NSMutableDictionary(listContent),但listContent的初始化似乎失败了,因此,无法从tmpDict转移内容。我做错了什么 谢谢 我的.h文件中的声明Ios5 NSMutableDictionary iVar初始化失败,ios5,nsmutabledictionary,Ios5,Nsmutabledictionary,试图从临时本地NSMutableDictionary(tmpDict)填充NSMutableDictionary(listContent),但listContent的初始化似乎失败了,因此,无法从tmpDict转移内容。我做错了什么 谢谢 我的.h文件中的声明 // .h NSMutableDictionary *listContent; ... @property (nonatomic, strong) NSMutableDictionary *listContent; - (void
// .h
NSMutableDictionary *listContent;
...
@property (nonatomic, strong) NSMutableDictionary *listContent;
- (void)viewDidLoad
{
NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] init];
//-- populating tmpDict here ....
//Bring to life, this dictionary
self.listContent = [NSMutableDictionary new];
//--- self.listContent is still not alive
if(!self.listContent)
NSLog(@"listContent is not alive, yet");
//populate self.listContent with contents of tmpDict
[self.listContent addEntriesFromDictionary:tmpDict];
//--- self.listContent is still not alive
if(!self.listContent)
NSLog(@"listContent is not alive, yet");
}
实施文件
// .h
NSMutableDictionary *listContent;
...
@property (nonatomic, strong) NSMutableDictionary *listContent;
- (void)viewDidLoad
{
NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] init];
//-- populating tmpDict here ....
//Bring to life, this dictionary
self.listContent = [NSMutableDictionary new];
//--- self.listContent is still not alive
if(!self.listContent)
NSLog(@"listContent is not alive, yet");
//populate self.listContent with contents of tmpDict
[self.listContent addEntriesFromDictionary:tmpDict];
//--- self.listContent is still not alive
if(!self.listContent)
NSLog(@"listContent is not alive, yet");
}
从LLDB切换到GBD修复了此问题。问题是我的字典在初始化并填充对象后被LLBD报告为nil。一旦我切换到GBD,所有的东西都被正确地初始化和水合了。我认为你最好使用
[NSMutableDictionary]
而不是[NSMutableDictionary new]
。是的。我试过了。没有变化。。。