[英]How can I get 2 properties from my fetch in my dictionary
I right now I have: 我现在有:
fetchRequest.resultType = NSDictionaryResultType;
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]];
which gives me something like this: 这给了我这样的东西:
self.dict=
(
{
realLocationName = "some where";
},
{
realLocationName = somewhereelse;
}
)
I want to get a second attribute value from cd in this dictionary but im not sure how? 我想从这本词典中的cd获取第二个属性值,但我不确定如何?
I tried doing something like this but it just overwrites the realLocationName with locationID 我试图做这样的事情,但它只是用locationID覆盖了realLocationName
fetchRequest.resultType = NSDictionaryResultType;
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]];
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"locationId"]];
On the 3rd line: 在第三行:
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"locationId"]];
you've overwritten what you'd set on the 2nd line: 您已经覆盖了第二行的设置:
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]];
You have to set one array as propertiesToFetch
: 您必须将一个数组设置为
propertiesToFetch
:
NSDictionary *properties = [entity propertiesByName];
fetchRequest.propertiesToFetch = @[properties[@"realLocationName"], properties[@"locationId"]];
I've used literals for creating and accessing NSArray
and NSDictionary
. 我使用文字来创建和访问
NSArray
和NSDictionary
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.