how can I count how many itens do I have inside of "bills"?
bills = (
{
id = 1;
name = "Cursus Nibh Venenatis";
value = "875.24";
},
{
id = 2;
name = "Elit Fusce";
value = "254.02";
}
);
I'm counting this way:
NSUInteger keyCount = [resultsDictionary count];
NSLog(@"%i", keyCount);
Thanks!
A naive solution would assume the OP wants to count bills
, which happens to be an array, so the solution would be
NSLog(@"Count: %i", [[resultsDictionary objectForKey: @"bills"] count]);
However, if you have a dictionary with more than one object you want to count, then enumerating them all is the only way to go.
NSUInteger keyCount = [resultsDictionary count];
NSLog(@"%i", keyCount);
is true but also you can use [resultsDictionary allKeys];
which will return an array of keys and you can directly get its count. For more, please visit docs :v
NSMutableArray *billsArray =[[NSMutableArray alloc] init];
billsArray = [resultsDictionary valueForKey:@"bills"];//returns array
NSUInteger keyCount = [billsArray count];
NSLog(@"%i", keyCount);
I think it will be helpful to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With