How can I use NSMutableArray to do something like below done before in C++.
vector BubblePacking (int _state, vector & _location_points, float _bubble_size);
I have created a Point2D class but I don’t know how to make it work as in c++
// ————-Point2D class
@interface EVAPoint2D : NSObject
{
float x;
float y;
}
@property float x,y;
-(void)setXY: (float) xVal: (float) yVal;
@end
// ————-Point2D implementation
@implementation EVAPoint2D
@synthesize x,y;
-(void) setXY:(float)xVal :(float)yVal{
x=xVal;
y=yVal;
}
@end
now how can I make let objective-C that I need to create a vector of Point2D elements using NSMutable array
thank you for your answers.
NSMutableArray Class Reference
You have to initialize an NSMutableArray with
myArr = [[NSMutableArray alloc] init];.Then, to add an object, instead of
push_back(myPoint), you use[myArr addObject:myPoint].To access a value, you use
[myArr objectAtIndex:i]rather thanmyVector[i].Also remember to release your point objects after you add them to the array, and release the array after you are done. (Unless, of course, you are using ARC)