mercredi 2 juillet 2014

Thread Signal SIGABRT Exception


Vote count:

0




I'm curious to know why I'm receiving an exception on this code and as to what this exception means. When I remove the for loop, as indicated below, it works fine. When I include it, I get an exception.



@interface MasterViewController ()

@property (nonatomic, strong) NSArray *venues;

@end

@implementation MasterViewController

- (void)awakeFromNib
{
[super awakeFromNib];
}

- (void)viewDidLoad
{
[super viewDidLoad];
[self configureRest];
[self loadVenues];
}

- (void) configureRest {

// initialize AFNetworking HTTPClient
NSURL *baseURL = [NSURL URLWithString:@"http://ift.tt/1jfBDuI"];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];

// initialize RestKit
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];

// setup object mappings
RKObjectMapping *venueMapping = [RKObjectMapping mappingForClass:[Venue class]];
[venueMapping addAttributeMappingsFromArray:@[@"name"]];

// register mappings with the provider using a response descriptor
RKResponseDescriptor *responseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:venueMapping
method:RKRequestMethodGET
pathPattern:@"/v2/venues/search"
keyPath:@"response.venues"
statusCodes:[NSIndexSet indexSetWithIndex:200]];

[objectManager addResponseDescriptor:responseDescriptor];
// define location object mapping
RKObjectMapping *locationMapping = [RKObjectMapping mappingForClass:[Location class]];
[locationMapping addAttributeMappingsFromArray:@[@"address", @"city", @"country", @"crossStreet", @"postalCode", @"state", @"distance", @"lat", @"lng"]];

// define relationship mapping
[venueMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"location" toKeyPath:@"location" withMapping:locationMapping]];

}

-(void) loadVenues {
NSString *latLon = @"34.0500, -118.2500"; // approximate latLon of The Mothership (a.k.a Apple headquarters)
NSString *clientID = kCLIENTID;
NSString *clientSecret = kCLIENTSECRET;
//34.0500° N, 118.2500

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];
//this for loop
for (int i =0; i < _venues.count; i++)

{
int index = 0;
for (Venue *venue in temp)
{
if(venue.location.distance > 0)
{
Venue *holder= [temp objectAtIndex:index];
[temp removeObjectAtIndex:index];
[temp addObject:[temp objectAtIndex:index+1]];
//replace a with a+1
[temp replaceObjectAtIndex:index+1 withObject:holder
];
//[temp addObject:holder atIndex: index+1];
//a[i+1]=holder;
index++;
}
else {index++;}

}

}


_venues = temp;
[self.tableView reloadData];
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"What do you mean by 'there is no coffee?': %@", error);
}];
}


asked 34 secs ago






Aucun commentaire:

Enregistrer un commentaire