mercredi 25 février 2015

How To Handle If Response Is nil, in objective-c

All,


How to handle if the response is nil.


if response do have any network issue it provided me string format.



if ([response isKindOfClass:[NSString class]]) {
// print response .
}
//on successfully response, which provided dictionary,
check for key success which do have true or false.
else if ([[response objectForKey:@"success"] boolValue] == true) {
// on true print response data.
}

//on success response, with failure message which is false.
else if ([[response objectForKey:@"success"] boolValue] == false) {
// handle error on success is false.
}


Here my question comes,if make response to nil response = nil; how to handle if response is nil? and satisfy the above the conditions also.


since manually i set response data is nil.


id response = nil; it trigger the below condition also.



else if ([[response objectForKey:@"success"] boolValue] == false) {
// handle error on success is false.
}


@All Thanks in Advance.




Aucun commentaire:

Enregistrer un commentaire