Ios 如何从字典中获取2个属性
我现在有:Ios 如何从字典中获取2个属性,ios,nsfetchrequest,Ios,Nsfetchrequest,我现在有: fetchRequest.resultType = NSDictionaryResultType; fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]]; 这给了我类似的东西: self.dict= ( { realLocationN
fetchRequest.resultType = NSDictionaryResultType;
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]];
这给了我类似的东西:
self.dict=
(
{
realLocationName = "some where";
},
{
realLocationName = somewhereelse;
}
)
我想从这本字典的cd中获取第二个属性值,但我不确定如何获取
我尝试过这样做,但它只是用locationID覆盖了realLocationName
fetchRequest.resultType = NSDictionaryResultType;
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]];
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"locationId"]];
在第三行:
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"locationId"]];
您已覆盖在第2行上设置的内容:
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]];
您必须将一个数组设置为propertiesToFetch
:
NSDictionary *properties = [entity propertiesByName];
fetchRequest.propertiesToFetch = @[properties[@"realLocationName"], properties[@"locationId"]];
我曾用于创建和访问NSArray
和NSDictionary