I'm trying to add the values in array and storing that array in dictionary. Actually, there are sections in UICollectionView, and each section contains items in it. Each time the array adds values for a section, it adds it into dictionary then clears the array and again next time the array add values for next section and and put to dictionary, but dictionary not holding the value when array objects removed. Below is code i tried.
NSMutableArray *arrStatus = [seatsDict objectForKey:0];
if(arrStatus == nil)
{
NSMutableArray *array = [NSMutableArray array];
array = arrSeatsStatus;
[seatsDict setObject:array forKey:[NSString stringWithFormat:@"%d",i]];
i++;
[arrSeatsStatus removeAllObjects];
}
else{
NSLog(@"arrStatus:%@", arrStatus);
[seatsDict setObject:arrSeatsStatus forKey:[NSString stringWithFormat:@"%d",i]];
i++;
[arrSeatsStatus removeAllObjects];
}
In above code array arrStatus is null always, but dictionary is not. Above code not giving desired results. Above code makes dictionary empty when array cleared. Please guide for above.
NSMutableArray *array = [NSMutableArray array]; array = arrSeatsStatus;- what for? Leaking memory 'cause it's fun or what?