我得到这个NSMutableDictionary
包含一个对象和一个键。关键是:TemplateID 和 Object 是一个数字。我的问题是我不能把对象拿出来,没有钥匙。
任何人都可以帮忙吗?
// Defining stuff...
templateData = [[NSMutableArray alloc] initWithCapacity:0];
[templateData addObjectsFromArray:[[WebXML sharedInstance] extractAddTemplate]];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:templateData, @"TemplateID", nil];
// First method...
NSArray *keys = [dict allKeys];
id aKey = [keys objectAtIndex:0];
id anObject = [dict objectForKey:aKey];
NSLog(@"anObject: %@", anObject);
// In NSLog it says: anObject: TemplateID = <theObject>;
// I just want anObject: <theObject>
// Second method...
for (id key in dict) {
id anObject = [dict objectForKey:key];
NSLog(@"anObject: %@", anObject);
// In NSLog it says: anObject: TemplateID = <theObject>;
// I just want anObject: <theObject>
}
// Third method...
NSArray * myArray = [NSArray arrayWithObject:@"TemplateID"];
NSMutableDictionary *anotherDict = [[NSMutableDictionary alloc] initWithObjects:templateData forKeys:myArray];
NSLog(@"anotherDict: %@", anotherDict);
// In NSLog it says: anotherDict: TemplateID = <theObject>;
// I just want anotherDict: <theObject>
// 米克尔