Reputation: 163
Is it possible to get number of rows in multi dimensional array?
Eg:
NSString *array[][2]={{@"1", @"2"},{@"1", @"2"}}
Not number of columns (2) but number of rows.
Upvotes: 1
Views: 82
Reputation: 131398
You are using C arrays of NSObjects, which is not recommended. I believe that will cause your NSNumbers to be zombies, since the Objective C runtime doesn't know how to memory-manage pointers to objects that are inside C arrays or structs. Thus it won't be aware that those objects are owned, and they will get deallocated.
It might be that Apple has solved this problem, but I don't think so.
Apparently I was wrong. It seems that the runtime does know how to memory-manage C arrays of object pointers, at least static-sized ones. Interesting. It still can't handle objects inside C structs however. Interesting.
Upvotes: 0
Reputation: 4586
const int numRows = sizeof(array)/sizeof(0[array]);
But may be it will be better to use NSArray:
NSArray* array = @[@[@"1", @"2"], @[@"1", @"2"]];
Upvotes: 2