ios - ReactiveCocoa- Error in map method -


i'm writing method gets signal webservice , converts nsdictionary object. if there's error happening in conversion?

will return racsignal error:error] then?

[signal map:^id(nsdictionary *dictionary) {     nserror *error;     samwebserviceresponse *samresponse = [mtljsonadapter modelofclass: samwebserviceresponse.class                                                    fromjsondictionary: dictionary                                                                 error: &error];     if (error) {         //todo: don't know if way go.         return [racsignal error:error];     } else {         return samresponse;     }   } ] 

reactivecocoa has construct situation called trymap:. check out:

[signal trymap:^id(nsdictionary *dictionary, nserror **errorptr) {     return [mtljsonadapter modelofclass:samwebserviceresponse.class                      fromjsondictionary:dictionary                                   error:errorptr]; }] 

this assumes modelofclass:fromjsondictionary:error: return nil when error occurs -- pretty standard -- it's worth checking docs on in case. code you've written return error signal, legitimate thing (signals of signals best part of rac), not want here.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -