Re: [問題] 如何在寫一個request去fetch core data …
※ 引述《Gsus (肉元,吉米,助教)》之銘言:
: 我大概知道要寫一個NSFetchRequest:
: NSFetchRequest *request = [[NSFetchRequest alloc] init];
物件用完記得 release
: NSEntityDescription *entity
: = [NSEntityDescription entityForName:@"Person"
: inManagedObjectContext:self.managedObjectContext];
: [request setEntity:entity];
: 但是接下來的expression我不知道該怎麼寫才能找出person name為john的
用 NSPredicate。從你的 code 繼續寫下去的話
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"name like %@", @"John"];
[request setPredicate:predicate];
NSError *error = nil;
NSArray *array = [context executeFetchRequest:request error:&error];
NSLog(@"array:%@", array); // 倒出來看
其實文件都有說:http://0rz.tw/nz3yT
--
zonble.net
cocoa.zonble.net
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.42.192.60
推
08/26 09:40, , 1F
08/26 09:40, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章