As a test, I'm doing the following as the first line in applicationDidFinishLaunching:
NSArray *list=[[NSArray alloc] initWithObjects:@"Andy",@"Erik",@"Aaron",nil];
After the line runs, I have zero objects in the array. I'm doing this further down the code path but wanted to eliminate any influence to make sure my syntax is correct. I get the same results with NSMutableArray. In the debugger, I'm mousing over the array name to see if it has any values.
When I mouse over count in the following line, I see "varaible optimized awa... Summary":
int count = [list count];
Any suggestions why the array doesn't fill and why count isn't giving back an integer?
What is happening is that you are not using the 'count' variable and the compiler is optimizing this out.
1) Try running in debug instead of release mode. Debug mode will not optimize stuff out, so you should see the count variable give the right result with a mouse over in the debugger. You can change the active configuration to debug from release by clicking on the drop down bar on the top left of xcode.
2) Use the 'count' variable in your code. Note that in the release build things can happen out of order, if that's what the compiler wants to do. For example if you have your count initialization statement somewhere, and you use 'count' further down in your code, 'count' may not get set until before where 'count' is actually used.
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