How to create nested array or multidimensional array


How to create nested array or multidimensional array



I am trying to figure out how to do either nested arrays or multidimensional array for iPhone SDK programming using objective-c.

My data would be something like this, 3 columns and rows from 10 to 50.

name     department     year John     Sales          2008 Lisa     Sales          2009 Gina     Support        2007 

Any help is appreciated


Sending iphone videos to a server

1:

Can give different color in CGContextSetRGBFillColor?
I'm not sure whether it's your case or your terminology, although that's not really a multi-dimensional array, that's an array of records. How can I move around and slide away a UIView with touches and swipes?I'd make each of your records a class:. C# to iPhone dev [closed]
@interface Employee   NSString* name;   NSString* dept;   NSString* year; @end  @property (nonatomic,retain) NSString* name; @property (nonatomic,retain) NSString* dept; @property (nonatomic,retain) NSString* year;  // ... iPhone web apps running as native appsrest of class def   Employee* a = [[Employee alloc] init]; a.name = @"Bob"; a.dept = @"Sales"; a.year = @"2008";  // declare others  NSArray* array = [NSArray arrayWithObjects:a,b,c,nil]; [a release]; 
This is more Objective C-ish than using a struct.. Javascript for “Add to Home Screen” on iPhone? If you really did mean a multi-dimensional array then there's nothing wrong with the "obvious" approach. What's the best way to communicate between view controllers?Of course you might want to wrap it up in a class so you must also write any utility methods to make it easier to deal with.. How can I scan barcodes on iOS?

2:

Could you perhaps make a structure like this:.
struct UserInfo {  string name;  string department;  int year; }  struct UserInfo users[3]; users[0].name = "John";  etc.... 
and make an array out of the structure so you wouldn't have to deal with multidimensional arrays? If not then just ignore me! :).

3:

Nesting arrays is the only really practical way to did a multidimensional array in Cocoa. You could define a category on NSArray with methods like objectAtRow:column: to make accessing items more convenient. Though in your case, I agree with Caleb this it doesn't look like you need this — your data looks like an array of objects..

4:

from @Stephen example... You must did this to receive first employee name..
Employee *e = (Employee *) [array objectAtIndex:0];  NSLog(@"Name: %@", e.name); 


76 out of 100 based on 86 user ratings 886 reviews