I'm trying to store data in NSMutableDictionary
. continue change NSString
value I want to store this value in NSMutableDictionary
, but when second time store value in NSMutableDictionary
then clear old value so how to store one by one value in NSMutableDictionary
.
NSString *tempitemname = itemselectedlbl.text;
NSString *temprate = ratelbl.text;
NSString *tempquant = quantitylbl.text;
NSString *temptotal = totallbl.text;
NSString *temptotalbill = totalbilllbl.text;
dict = [[NSMutableDictionary alloc]init];
[dict setValue:tempitemname forKey:@"itemname"];
[dict setValue:temprate forKey:@"rate"];
[dict setValue:tempquant forKey:@"quantity"];
[dict setValue:temptotal forKey:@"total"];
[dict setValue:temptotalbill forKey:@"totalbill"];
Continue change all labels value I want store these values in NSMutableDictionary
.
NSDictionary/NSMutableDictionary doesn't allow duplicate key to store inside them. So when you set the values second time then it overwrites the data if there is already a key available inside the dictionary. So you can't store again and again and still expect it to hold all the data.