objective c - UnwindToList with multiple NSMutableArrays -
ok have 7 nsmutablearrays , connected tableview first table-view tells second table-view 1 load, , loads fine, each 1 want able add item/cell, load 1 of views. here nsmutablearrays list of items , properties.
properties:
@property (nonatomic) nsmutablearray *movies; @property (nonatomic) nsmutablearray *tv_shows; @property (nonatomic) nsmutablearray *resturuants; @property (nonatomic) nsmutablearray *video_games; @property (nonatomic) nsmutablearray *concert_venues; @property (nonatomic) nsmutablearray *foods; @property (nonatomic) nsmutablearray *recipes
nsmutablearray items
_movies = [[nsmutablearray alloc]initwithobjects:@"avatar", @"kung fu panda", @"the matrix", nil]; _tv_shows = [[nsmutablearray alloc]initwithobjects:@"reguluar show", @"kung fu panda", @"avatar last airbender", nil]; _resturuants = [[nsmutablearray alloc]initwithobjects:@"outback steakhouse", @"golden corral", @"wendy's", nil]; _video_games = [[nsmutablearray alloc]initwithobjects:@"black ops", @"call of duty", @"modern warfare", nil]; _foods = [[nsmutablearray alloc]initwithobjects:@"baked bread", @"pasta", @"italian meatballs", nil]; _recipes = [[nsmutablearray alloc]initwithobjects:@"chocolate cookies", @"brownies", @"peanutbutter fudge", nil]; _concert_venues = [[nsmutablearray alloc]initwithobjects:@"pheonix", @"buckeye", @"maricopa", nil];
unwind list method loads first item.
- (ibaction)unwindtotableviewcontroller:(uistoryboardsegue *)sender { addviewcontroller *addviewcontroller = (addviewcontroller *)sender.sourceviewcontroller; nsstring *text = addviewcontroller.textfield.text; //if not blank , not whitespace if (![text length] == 0 && ![[text stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset]] length] == 0) { //add top of data source. [_movies insertobject:text atindex:0]; nsindexpath *indexpath = [nsindexpath indexpathforrow:0 insection:0]; //insert tableview [self.tableview beginupdates]; [self.tableview insertrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; [self.tableview endupdates]; } }
//add top of data source. [_movies insertobject:text atindex:0]; nsindexpath *indexpath = [nsindexpath indexpathforrow:0 insection:0];
as can see _movies being loaded, have same _tvshows,restaurants, etc... increasing values (as in not 0). example
[_restaruants insertobject:text atindex:1]; nsindexpath *indexpath = [nsindexpath indexpathforrow:1 insection:1]; //you may have keep insection:0, try 1 anyway
Comments
Post a Comment