經過實驗後,我意識到這段代碼只適用於64位iPhone,而不適用於其他版本。不在iPad上,不在我自己的設備上(iPhone 5),不在任何未指定爲64位的東西上。這是爲什麼?代碼適用於64位iPhone,但不適用於其他任何人......爲什麼不呢?
- (void)loadVenues {
NSString *latLon = @"30, -120";
NSString *clientID = kCLIENTID;
NSString *clientSecret = kCLIENTSECRET;
NSDictionary *queryParams = @{@"ll" : latLon,
@"client_id" : clientID,
@"client_secret" : clientSecret,
@"categoryId" : @"4bf58dd8d48988d1e0931735",
@"v" : @"20140118"};
[[RKObjectManager sharedManager] getObjectsAtPath:@"/v2/venues/search"
parameters:queryParams
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
{
_venues = mappingResult.array;
NSMutableArray *temp = [(NSArray*)_venues mutableCopy];
Venue *holder;
for (int i = 0; i < _venues.count; i++) {
for (int j = 0; j < i; j++) {
if (((Venue *) [temp objectAtIndex:i]).location.distance < ((Venue *) [temp objectAtIndex:j]).location.distance) {
holder = [temp objectAtIndex:j];
[temp replaceObjectAtIndex:j withObject:[temp objectAtIndex:i]];
[temp replaceObjectAtIndex:i withObject:holder];
}
}
}
_venues = temp;
[self.tableView reloadData];
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"What do you mean by 'there is no coffee?': %@", error);
}];
}
到底什麼是不工作呢?一個例外,邏輯錯誤? – Oxcug
你不要「排序算法」,你使用「排序算法」 – michaelsnowden
@theMonster我沒有收到任何異常錯誤,它似乎沒有按照正確的順序加載數組。它似乎是隨機序列加載的。 – user3205630