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; } 

  1. - requestpanoramanearcoordinate:callback: asynchronous request. started , code execution not blocked. if (!panphoto) return [self randomlatitudelongitude]; called panphoto being still nil, return statement performed.

  2. 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

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -