samedi 31 janvier 2015

iOS Completion Block Returning (null)


Vote count:

0




I am running a class method that has a completion block with an object that I want to return. However, when I get the value back, the properties are all there but the debugger says that object is (null) despite having a memory address when looking at more details. Does anyone know how this can be possible. Thanks!!


I have also attached an image to my debug area where the (null) is shown


http://ift.tt/1DsFHxd



+ (void)getBoard:(NSInteger)boardId withUser:(User *)user completion:(void (^)(Board *board))compBoard {
NSDictionary* headers = @{@"Accept": @"application/json", @"Authorization": [NSString stringWithFormat:@"Bearer %@", user._token]};
[[UNIRest get:^(UNISimpleRequest *request) {
[request setUrl:[NSString stringWithFormat:@"%@/boards/%zd", REST_URL, boardId]];
[request setHeaders:headers];
}] asJsonAsync:^(UNIHTTPJsonResponse *jsonResponse, NSError *error) {
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:[jsonResponse rawBody] options:kNilOptions error:&error];
NSLog(@"Response status of boards: %ld\n%@", (long) jsonResponse.code, json);
if ( jsonResponse.code >= 200 && jsonResponse.code <= 300 ) {
NSDictionary *boardDict = [NSJSONSerialization JSONObjectWithData:[jsonResponse rawBody] options:kNilOptions error:&error];

Board *board = [[Board alloc] init];

board._courseId = [[boardDict objectForKey:@"courseId"] integerValue];
board._udid = [[boardDict objectForKey:@"boardId"] integerValue];
board._boardName = [boardDict objectForKey:@"name"];
NSDate *dateModified = [NSDate convertFromStringFromRemote:[boardDict objectForKey:@"lastModified"]];
board._dateModified = dateModified;
NSDate *dateCreated = [NSDate convertFromStringFromRemote:[boardDict objectForKey:@"createdDate"]];
board._dateCreated = dateCreated;

compBoard(board);
}
}];
}


asked 1 min ago







iOS Completion Block Returning (null)

Aucun commentaire:

Enregistrer un commentaire