queue - NSArray is null when i create it in the completion whereas the first nsarray is not null -


this code trying create nsmutable array strings , store them in object property. nsarray *photos works not nsmutablearray thumbimageurl. when nslog debugging purposes null. please help, annoys me lot, cant find solution. lazy instantiated there no reason not have allocation in memory.

lazy instantiation:

-(void)setthumbimageurl:(nsmutablearray *)thumbimageurl {     if (!_thumbimageurl) _thumbimageurl=[[nsmutablearray alloc] initwithcapacity:50];     _thumbimageurl=thumbimageurl; } 

my code:

[pxrequest requestforphotofeature:pxapihelperphotofeaturepopular resultsperpage:50 page:1 photosizes:(pxphotomodelsizelarge | pxphotomodelsizethumbnail | pxphotomodelsizesmallthumbnail |pxphotomodelsizeextralarge) sortorder:pxapihelpersortordercreatedat completion:^(nsdictionary *results, nserror *error) {          [[uiapplication sharedapplication] setnetworkactivityindicatorvisible:no];          if (results) {             self.photos =[results valueforkey:@"photos"];             nslog(@"%@",self.photos);         }          nslog(@"\n\n\n\n\n\n\n\nself photos count  : %lu",[self.photos count]);         (int i=0; i<[self.photos count]; i++)         {             nsurl *thumbimageurl= [nsurl urlwithstring:[[[self.photos valueforkey:@"images"] [i] valueforkey:@"url"] firstobject]];             nsdata *imagedata=[nsdata datawithcontentsofurl:thumbimageurl];                [self.thumbimageurl addobject:imagedata];             self.largeimageurl[i]=[[[self.photos valueforkey:@"images"] [i] valueforkey:@"url"] lastobject];          }         nslog(@"\n\n\n\n\n\n\n\nself thum image after  : %@",self.thumbimageurl);         nslog(@"\n\n\n\n\n\n\n\nself large image after  : %@n\n\n\n\n\n\n\n",self.largeimageurl);      }]; 

i myself found problem. problem lazy instantiation on setter whereas should on getter


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -