![](/img/trans.png)
[英]ios How to properly use NSPredicate for NSString matching with Core Data?
[英]How can I create and use NSPredicate with queries in iOS's Core Data?
如何在iOS的核心數據中創建NSPredicate
與查詢一起使用?
“查詢”是指NSFetchRequest
嗎? 如果是這樣,這是一個簡單的示例:
假設您有一個名為Car的實體,並且它的牌照號為NSString
類型的“ licenceNumber”。
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"Car" inManagedObjectContext:yourObjectContext]];
[request setPredicate:[NSPredicate predicateWithFormat:@"licenceNumber==%@", theLicensePlateNumberYouWant]];
話雖如此,您可能想花一些時間先閱讀Apple的文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.