Prise en bloc incompatible types de pointeur envoi void *(^)
[AsyncRequest performGetRequestWithUrl:[NSString stringWithFormat:@"http://%@/api/streams/%d", @"server.herokuapp.com", userId]
completionHandler:^(NSDictionary *result, NSError *error) {
//Create new SBJSON parser object
NSError *e;
NSArray *jsonArray =[NSJSONSerialization JSONObjectWithData:result options:NSJSONReadingMutableContainers error: &e];
NSLog(@"parse result to JSON object with jsonArray: %@ and error: %@", jsonArray, e.description);
if ([jsonArray valueForKey:@"error"]) {
return nil;
}
NSLog(@"getStreams size of the return array: %d", [jsonArray count]);
NSMutableArray* data = [[NSMutableArray alloc] initWithCapacity:0];
if (jsonArray) {
data = [[NSMutableArray alloc] initWithCapacity:[jsonArray count]];
for (NSDictionary *item in jsonArray) {
NSLog(@"item: %@", item);
[data addObject:[[Stream alloc] initWithJSONObject:item]];
}
}
onComplete(data, error);
}];
Je suis bizarre erreur sur ce code. Il affiche le message d'erreur "prise en bloc incompatible types de pointeur envoi void *(^)(NSDictionary *_strong, NSError *_strong) pour le paramètre de type 'void (^)(NSDictionary *_strong, NSError *_strong)'
Voici la signature de fonction:
+(void)performGetRequestWithUrl:(NSString *)requestUrl completionHandler:(void (^)(NSDictionary *result, NSError *error))completionBlock
Vous devez vous connecter pour publier un commentaire.
changement "retourner nil" à "revenir"
void *
à un paramètre qui s'attend à un bloc de retourvoid
. En C et Objective-C,void *
est le type de l'arbitraire d'un pointeur;nil
est en fait défini pour êtrevoid *(0)
ainsi, lorsque vous tapezreturn nil
le compilateur déduit de votre type de retour devoid *
. Alors que si vous n'ayant rien après votrereturn
déclaration, ou pasreturn
, il induit un type de retour devoid
, comme prévu par le paramètre.