Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何从字典中获取2个属性_Ios_Nsfetchrequest - Fatal编程技术网

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