フェッチリクエストを使用して取得した値を、コアデータグラフから配列に配置する必要がありますが、これについての詳細はわかりません。コアデータ値を配列に入れよう
私はフェッチを実行するために、次を使用しています:あなたが見ることができるように
NSString *entityName = @"Project"; // Put your entity name here
NSLog(@"Setting up a Fetched Results Controller for the Entity named %@", entityName);
// 2 - Request that Entity
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:entityName];
// 3 - Filter it if you want
request.predicate = [NSPredicate predicateWithFormat:@"belongsToProject = %@", _selectedProject];
// 4 - Sort it if you want
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"dateTaken"
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)]];
// 5 - Fetch it
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
managedObjectContext:self.managedObjectContext
sectionNameKeyPath:nil
cacheName:nil];
[self performFetch];
を、私はNSPredicateを使用して戻ってくる値をフィルタリングしています。
これらの値を配列にどのようにして取得し、エンティティの個々の属性(配列の中にある場合はproject.descriptionやproject.nameなど)を選択することもできますか?
- ループから属性を選択します。私は、配列内のオブジェクトを持っているEimantasに
おかげで、しかし、私はまだ2つのことを行う必要があります配列、例えば、プロジェクトの記述。
私が最初に実行するループのために、以下を使用しています:
for (int i=0; i < [projectListArray count]; i++)
{
NSString *tmp = (NSString *)[projectListArray objectAtIndex:i];
}
しかし、これはエラーを返して:
-[Project length]: unrecognized selector sent to instance 0x1b9f20
2012-03-28 10:48:35.160 Project App[3973:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Project length]: unrecognized selector sent to instance 0x1b9f20'
私はインクリメントされないことがありますかのようにそれが表示されます?
ブリリアント、高価なEimantas。あなたが手伝ってもらえない場合は、私がやろうとしていることがありますか?私は元の質問を更新しました。 – jcrowson