我有一个名为Route
的实体,以及来自该实体的名为Longitude
和Latitude
的两个属性。 该应用程序的功能很简单:它将从Longitude
和Latitude
中获取数据并创建一个NSArray。获取核心数据中两个属性的正确方法
例如:
Route 1 has Longitude=2 and Latitude=41
Route 2 has Longitude=3 and Latitude=42
Route 3 has Longitude=4 and Latitude=43
所以结果将是一个NSArray的与内容:
{
[[CLLocation alloc] initWithLatitude:41 longitude:2],
[[CLLocation alloc] initWithLatitude:42 longitude:3],
[[CLLocation alloc] initWithLatitude:43 longitude:4],
}
但问题是,如果我取不同setupFetchedResultsController两个属性,我不能“连接“他们与他们合适的合作伙伴(我会得到2个分开的值列表)。是否有另一种方法来从2个属性“连接”中获取数据?
这是我的一个fetchedResultsController
如果有人需要看到:
- (NSFetchedResultsController *)fetchedLatitudController
{
if (_fetchedLatitudController != nil) {
return _fetchedLatitudController;
}
// 1 - Decide what Entity you want
NSString *entityName = @"Route"; // Put your entity name here
// 2 - Request that Entity
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:entityName];
// 4 - Sort it if you want
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"latitude"
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)]];
// 5 - Fetch it
self.fetchedLatitudController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
managedObjectContext:self.managedObjectContext
sectionNameKeyPath:nil
cacheName:nil];
[self.fetchedLatitudController performFetch:nil];
return _fetchedLatitudController;
}
请显示您的代码。你如何获取属性? –
我使用setupfetchedResultsController的通用模板来提取。 – Rodrigo