I’m trying to create an array of b2Vec2 arrays using inline declaration. Right now I have…
NSMutableArray *array = [[NSMutableArray alloc] init];
b2Vec2 temp1[] = {
*new b2Vec2(1,1),
*new b2Vec2(0,0)
};
[array addObject:(id)temp1];
b2Vec2 temp2[] = {
*new b2Vec2(1,1),
*new b2Vec2(0,0)
};
[array addObject:(id)temp2];
b2Vec2 temp3[] = {
*new b2Vec2(1,1),
*new b2Vec2(0,0)
};
[array addObject:(id)temp3];
Is there any way I can get the temp1, temp2, and temp3 declaration inline with the addObject method call? Something like this…
[array addObject:<some inline array instantiation>];
[array addObject:<some inline array instantiation>];
[array addObject:<some inline array instantiation>];
Thanks!
No, you cannot do that. You have to declare the array temp1-3 before you can use it in
[array addObject:]statement. One thing you can do is creating another function that initializes and returns the array you need.