从其他NSMutableDictionary保存和检索NSMutabledictionary

时间:2013-09-28 14:58:41

标签: ios

我有NNDictionary,我想将其存储在另一个NSMutableDictionary中。我是这样做的:

NSDictionary* dictionary = (NSDictionary*) [NSKeyedUnarchiver unarchiveObjectWithData:context];
    [myDictionarySTORE setObject:dictionary forKey:[NSString stringWithFormat:@"%d", r]];

要提取它,我会这样做:

NSDictionary* dic = [myDictionarySTORE objectForKey:[NSString stringWithFormat:@"%ld", (long)btn.tag]];
NSString *Name = [dic objectForKey:@"fileName"];
NSString *Type = [dic objectForKey:@"fileType"];
NSData *File = [dic objectForKey:@"FileData"];

这种情况下的btn.tag是r。键是相同的,但它似乎不起作用......

1 个答案:

答案 0 :(得分:-1)

NSDictionary * dic = [NSDictionary dictionaryWithDictionary:[myDictionarySTORE objectForKey:[NSString stringWithFormat:@“%ld”,(long)btn.tag]]];

或者

NSDictionary * dic = [[NSDictionary alloc] initWithDictionary:[myDictionarySTORE objectForKey:[NSString stringWithFormat:@“%ld”,(long)btn.tag]]];