I'm trying to improve performance for my application, and I'd like to change from the NSMutableArray I'm currently using to a dynamically allocated C array.
As a test, I've created this class:
In my class interface, I have:
MyObject *myObjectArray;
In my implementation, after the object has been initialised, I have another method to set up the array:
-(void) createObjectsWithNumberOfObjects:(int)numberOfObjects
{
MyObject *tempObject = nil;
myObjectArray = (MyObject*) malloc(numberOfObjects * sizeof(tempObject));
for( int i = 0; i < numberOfObjects; i++ )
tempObject = [[MyObject alloc] init];
myObjectArray[i] = (MyObject*) tempObject; // error
}
}
I'm getting an error of: Incompatible Types In Assignment
So what am I doing wrong?
Is using a dynamically allocated array of objects like this possible?
Also, In my dealloc method, I have it setup to call release on each object then free(myObjectArray)