I am having an issue where I am trying to take an NSInteger, and place the value into a label. Here is the code:
NSArray *itemList = [cart objectForKey:@"CartItemList"];
NSInteger itemCount;
for(NSDictionary* cartItem in itemList) {
itemCount += [[cartItem valueForKey:@"Quantity"] integerValue];
}
[totalItems setText:[NSString stringWithFormat:@"%d",itemCount]];
Item list has one item with a Quantity of 4, however, the label is showing the pointer reference number, not the value of 4. What am I missing?
Thanks in advance for your help!
Try this :
You didn’t tell it you wanted to start counting from 0 🙂