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
Post a Comment