Yes, you are correct exactly. NSLog
prints text to the console window, and the count
function of an array outputs the number of elements in that array.
NSLog prints text in a special way; wherever there is a %i
, %d
, %f
, %@
, etc, it replaces that symbol with a passed variable. So if I typed:
NSLog(@"Hi my name is %@. I am %i years old.", @"Sarah", 12);
The console would print:
Hi, my name is Sarah. I am 12 years old.
So in your example, if annotations has 10 elements, 10
will simply be printed to the console. This can get confusing if you simply print a bunch of numbers though! So using NSLog's flexibility, it would be easier to read your log output if you did this:
NSLog(@"Elements in annotations array: %d", [annotations count]);
Then this would be printed to your console:
Elements in annotations array: 10
Which might be more helpful when reading back through your logs!