You would utilize the alloc
and init
(or more specialized initializer) provided by NSObject
.
For example, something like the following should work:
int fromuser, a;
NSMutableArray objectArray = [[NSMutableArray alloc] initWithCapacity:fromuser];
for (a = 0; a < fromuser; a++)
{
MyObject *obj = [[MyObject alloc] init];
[objectArray addObject:obj];
[obj release]; //If not using ARC
}
2
solved New and delete command of c++ in obj-c