简体   繁体   English

NSMutableArray iPhone的核心数据实体属性值

[英]Core data entity attribute values to NSMutableArray iPhone

I am using this code to fetch the core data results: 我正在使用以下代码来获取核心数据结果:

-(void)getData {

NSEntityDescription *entity = [NSEntityDescription entityForName:@"Favouritesdata" inManagedObjectContext:context];

NSFetchRequest *request = [[NSFetchRequest alloc] init];

[request setFetchBatchSize:20];

[request setEntity:entity];

NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"licenseplate" ascending:NO];

NSArray *newArray = [[NSArray alloc]initWithObjects:sort, nil];

[request setSortDescriptors:newArray];

NSError *error;
results = [[context executeFetchRequest:request error:&error] mutableCopy];

NSLog(@"results::::: %@", results);

[self setLicensePlateArray:results];

[self.favouritesTable reloadData];

}

Here in this entity Favouritesdata, I have an attribute with the name of license plate, I want to get this attribute values to NSMutableArray. 在这个Favouritesdata实体中,我有一个带有牌照名称的属性,我想将此属性值获取到NSMutableArray。

How can I get these values? 如何获得这些值?

You can use NSPredicate and directly get the value by passing the predicate in the request. 您可以使用NSPredicate并通过在请求中传递谓词直接获取值。 Refer this link for more information http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html 请参阅此链接以获取更多信息http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM