Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add and extract struct from NSMutableArray [duplicate]

Possible Duplicate:
What’s the best way to put a c-struct in an NSArray?

I need to create an array of structures, such as:

typedef struct
{
    int fill;
    BOOL busy;
} MapCellST;

How can I add instances of this structure in NSMutableArray and how I can extract copies of the structure and work with its properties later?

like image 334
Andrey Avatar asked Dec 22 '22 15:12

Andrey


1 Answers

Wrap the struct in an NSValue:

MapCellSt x;
NSValue* value = [NSValue value:&x withObjCType:@encode(MapCellSt)];

To extract it later:

[value getValue:&x];
like image 120
Tamás Avatar answered Dec 24 '22 04:12

Tamás