2013-10-09 31 views
0

我现在我有:我怎样才能从我的2个属性在我的字典里取

fetchRequest.resultType = NSDictionaryResultType; 
    fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]]; 

,给了我这样的事情:

self.dict= 
    (
      { 
      realLocationName = "some where"; 
     }, 
      { 
      realLocationName = somewhereelse; 
     } 
    ) 

我希望得到一个第二属性值从这个字典中的CD,但我不知道如何?

我试图做这样的事情,但它只是会覆盖locationID

fetchRequest.resultType = NSDictionaryResultType; 
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]]; 
fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"locationId"]]; 

回答

0

的realLocationName 3号线:

fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"locationId"]]; 

你覆盖你会二号线设置:

fetchRequest.propertiesToFetch = [NSArray arrayWithObject:[[entity propertiesByName] objectForKey:@"realLocationName"]]; 

你必须设置一个数组作为propertiesToFetch

NSDictionary *properties = [entity propertiesByName]; 
fetchRequest.propertiesToFetch = @[properties[@"realLocationName"], properties[@"locationId"]]; 

我用literals用来创建和访问NSArrayNSDictionary