AykutE
AykutE

Reputation: 36

How do I create a multidimensional array?

I need to keep 90x90 array data for iphone app. how can i keep this data? making an multi-dimensional array is a solution for this big table. or is there an other solution.

Upvotes: 1

Views: 1127

Answers (3)

Caleb
Caleb

Reputation: 124997

You can:

  • Use a single Obj-C array containing 8100 elements and map your rows and columns onto the single index yourself: index = (row * 90) + column;

  • Create an Obj-C array containing 90 Obj-C arrays of 90 elements each.

  • Hash the row and column together into a single key that you can use with a dictionary. This could be a good solution especially if the array is sparse.

  • Use a single- or multi-dimensional C array, especially if the elements of the array are plain old C types, like int. If you're storing objects, it's better to go with an Obj-C container.

Upvotes: 1

Jeffery Thomas
Jeffery Thomas

Reputation: 42588

If the matrix is always 90x90, then you should just use C arrays.

Unless you have a special need for passing the matrix around, searching using predicates, or need some other feature of NSArray, then keep it simple.

Upvotes: 3

mistahenry
mistahenry

Reputation: 8724

Iphone's have a built in database SQL-Lite. I'd look into that to see if it meets you needs

Upvotes: 0

Related Questions