It's ok i go with NSMutableArray way...in Objective-C....
I wasn't sure if this is a question or not. If you are targeting the iPhone, using NSMutableArray is definitely an option. The things you cannot do with Cocoa Touch vs. Cocoa are many fewer than the things you can do. A downside to going with NSMutableArray is that you have to store NSObjects, so you would have to wrap each element in an NSNumber or some other wrapper class. If you really have something like 6 elements, this overhead would be negligible, but if you have millions of elements, the overhead might not be worth the simplicity.
but is there no other possible way where i can create 2-d arrays of a particular primitive type....
We have suggested 3 different methods already:
1) Wrapping the primitive in NSNumber and storing an NSMutableArray of NSMutableArrays.
2) malloc'ing space for a number of int *, then malloc'ing space for each row (or one big malloc for all of the primitives, then some slightly awkward pointer manipulation to break this memory up into rows). This requires tracking and free'ing of the pointers, though.
3) building a C++ class to handle the memory management for you. You could build 1 per primitive type, or you could likely build a single class that handles this with templates or generics. i do not know C++ well enough to say if this would actually be possible but it "feels" like it.
Are all of these ideas unsuitable? Any of them should work for you, but they all have advantages and disadvantages to consider. The NSMutableArray of NSMutableArrays will have the most overhead, followed by the C++ approach, which would have only a little overhead, followed by the C malloc approach, which would have no real overhead. However, they go in the reverse order in terms of complexity of memory management, with the C++ and Cocoa (NSMutableArray) methods being pretty equal in terms of complexity.
Describing your problem more clearly might help us suggest which of these methods is best, or even a completely different method. However, at this point it seems like you've been given more than enough suggestions. Before anyone comes up with any other ideas on how one might store a dynamic number of primitives that can be accessed via two indicies (which there are basically an infinite number of ways to do), you might want to provide more precise details on what you really need.
-Lee