ios - Creating UIImage array -


i've written code gathers images json requests , attempts add them nsmutablearray used later in table view. problem after adding image objects array, size of nsmutablearray 0. here relevant code:

@implementation example{     nsmutablearray *_placeimages; }  -(void)viewdidload{     ...     _placeimages = [[nsmutablearray alloc] init]; }  -(void)jsonquery {     ...     // retrieve results of url.     dispatch_async(kmyqueue, ^{     [self downloadimages];     [self performselectoronmainthread:@selector(reloadtabledata) withobject:null waituntildone:yes];     }); }  -(void)downloadimages{      ...      nsdata* data = [nsdata datawithcontentsofurl: url];     uiimage* image = [uiimage imagewithdata:data];     [_placeimages addobject:image]; } 

you must alloc nsmutablearray first:

_placeimages = [[nsmutablearray alloc] init]; 

or can using lazy init:

- (nsmutablearray *)placeimages {     if (!_placeimages) {        _placeimages = [[nsmutablearray alloc] init];     }     return _placeimages } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -