I am creating a validate method for my application, hover I am having problems with the return value;
Incompatible block pointer type sending char …
-(BOOL)validateEmail{
if (self.ownUser.emailUser != self.emailField) {
[UserAPIClient validateEmail:self.emailField sucess:^(BOOL sucess, NSError *error) {
if (sucess) {
return YES;
}else{
NSLog(@"Can´t change e mail, already one is created in the database");
return NO;
}
}];
}else{
return YES;
}
}
Can anybody help me solve this?
Thanks in advance…
EDIT
I completily missed the right solution, just adopt my UserApiClient to return a BOOL
-(BOOL)validateEmail{
if (self.ownUser.emailUser != self.emailField) {
return [UserAPIClient validateEmail:self.emailField];
}else{
return YES;
}
}
EDIT 2
Know, i just realized, that i need the result of this method to make some changes after.
How can i change this method to an sync´s Method?
[[MYApiClient sharedInstance] getPath:@"validateEmail" parameters:params
success:^(AFHTTPRequestOperation *operation, id JSON) {
NSLog(@"SUCESS %@", JSON);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error %@", error);
}];
If you want to use the value of
sucessoutside of the block, you have to copy it to a__blockvariable:The block itself (as I guess from the prototype) does not return a value.
Note that this will work only if
[User validateEmail:sucess:]works synchronously, so thatreturnValueis defined when the function call returns.