objective c - Obj-C: Callback is not executing -
any idea why callback not executing? panoservie
initialized , everything. put nslog messages there, , nothing happens.
- (cllocationcoordinate2d) randomlatitudelongitude { countrybbval aubb = [[ggdata sharedinstance] boundingboxforcountry:australia]; //nslog(@"bb: %f, %f, %f, %f", aubb.nelat, aubb.nelng, aubb.swlat, aubb.swlng); double ranlongitude = [self randomdoublebetween: aubb.nelng and: aubb.swlng]; // boundix box double ranlatitude = [self randomdoublebetween: aubb.nelat and: aubb.swlat]; cllocationcoordinate2d ranlatlng = cllocationcoordinate2dmake(ranlatitude, ranlongitude); //nslog(@"ranlatlng: [%f] [%f]", ranlatitude, ranlongitude); __block gmspanorama *panphoto = nil; [self.panoservice requestpanoramanearcoordinate:ranlatlng callback:^(gmspanorama *panorama, nserror *error) { nslog(@"panorama: %@ error: %@", panorama, error); panphoto = panorama; }]; if (!panphoto) return [self randomlatitudelongitude]; return ranlatlng; }
- requestpanoramanearcoordinate:callback:
asynchronous request. started , code execution not blocked.if (!panphoto) return [self randomlatitudelongitude];
calledpanphoto
being stillnil
,return
statement performed.overall method idea not seem right me.
- you should not have async block called in getter-like method (which should return result immediately). if want method this, should define own callback block method being called in
requestpanoramanearcoordinate
callback. - calling
return [self randomlatitudelongitude]
in method not idea. can cause infinite recursion. there should @ least max recursion calls threshold
- you should not have async block called in getter-like method (which should return result immediately). if want method this, should define own callback block method being called in
Comments
Post a Comment