ios - array has 10 nil objects? -
so have 4 types of arrays,
@property nsmutablearray *snowimagearray; @property nsmutablearray *dogimagearray; @property nsmutablearray *catimagearray; @property nsmutablearray *rabbitimagearray; these arrays store custom objects standardurl, username,etc . created array called
@property nsmutablearray *allimagearray; where stored 4 object arrays in allimagearray. want populate allimagearray in collection view.. far have in cellforitematindexpath method... looped through array this..
nsarray *allimagearray = [self.allimagearray objectatindex:indexpath.row]; nslog(@"%@",allimagearray); (nsmutablearray *searchdataimage in allimagearray) { (imagehelper *imagehelper in searchdataimage) { nsurl *url = [nsurl urlwithstring:imagehelper.standardphotourl]; nsdata *data = [[nsdata alloc]initwithcontentsofurl:url]; uiimage *image = [uiimage imagewithdata:data]; cell.imageview.image = image; } } now reason allimagearray has 10 objects literally have nothing in them prints 10 objects has @"0 objects".. instantiated allimagearray in viewdidload. double checked methods , made sure did 4 times dog, snow, rabbit & cat:
[self.rabbitimagearray addobject:imagehelper]; //adds objects array [self.allimagearray addobject:self.rabbitimagearray]; [self.tableview reloaddata] please tell me did wrong? :/
try initialize arrays before adding objects:
self.snowimagearray = [nsmutablearray new]; self.dogimagearray = [nsmutablearray new]; self.catimagearray = [nsmutablearray new]; self.rabbitimagearray = [nsmutablearray new]; self.allimagearray = [nsmutablearray new];
Comments
Post a Comment