Objective c ios 5上的核心数据性能

Objective c ios 5上的核心数据性能,objective-c,core-data,ios5,Objective C,Core Data,Ios5,我需要优化ios 5设备上的核心数据。虽然它在ios 6及以上版本上速度很快,但在ios 5设备上速度非常慢。我看到了这样的圆木 CoreData:注释:11行的总提取执行时间:1.0510s 我可以知道我的密码有什么问题吗?在ios 5设备上是否还有其他优化核心数据性能的好方法 - (NSArray *)getBusServiceAtBusStop:(NSString *)bus_stop_id { if (!bus_stop_id) return nil; NSFetchReq

我需要优化ios 5设备上的核心数据。虽然它在ios 6及以上版本上速度很快,但在ios 5设备上速度非常慢。我看到了这样的圆木

CoreData:注释:11行的总提取执行时间:1.0510s

我可以知道我的密码有什么问题吗?在ios 5设备上是否还有其他优化核心数据性能的好方法

- (NSArray *)getBusServiceAtBusStop:(NSString *)bus_stop_id  
{
if (!bus_stop_id)
    return nil;

NSFetchRequest *fetchrequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"BusRoute"
                                          inManagedObjectContext:[self managedObjectContext_busroutes]];
[fetchrequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"bus_stop_id == %@", bus_stop_id];
[fetchrequest setPredicate:predicate];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"bus_service_num" ascending:YES];
[fetchrequest setSortDescriptors:@[sortDescriptor]];

NSError *error = nil;
NSArray *arr = [[self managedObjectContext_busroutes] executeFetchRequest:fetchrequest error:&error];

if (error)
{
    DLog(@"Error: %@", [error localizedDescription]);

    return nil;
}

if ([arr count] <= 0)
{
    DLog(@"Empty array");

    return nil;
}

NSMutableArray *mutated = [NSMutableArray array];
NSMutableArray *reference = [NSMutableArray array];
for (BusRoute *busroute in arr)
{
    NSString *bus_service_num = busroute.bus_service_num;
    if ([reference containsObject:bus_service_num])
        continue;

    [reference addObject:bus_service_num];
    [mutated addObject:@{@"bus_service_num": bus_service_num, @"bus_type": busroute.bus_type}];
}

return [NSArray arrayWithArray:mutated];
}

老实说,我不会担心iOS5设备。只要你在6+上表现良好。基于此页面,只有不到5%的用户使用6或更低版本:我认为您已经发现了核心问题:在较新版本的iOS上,核心数据更高效。