Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

D.A.N.

macrumors newbie
Original poster
My problem here is that I have created 2 classes. One called Object, of which there will be multiple instances created, holding coords, and a few other bits of information about the object, and another called level. This one will be used to create and manage these instances.

#import "Object.h"

@implementation Object

-(void) Create {

coordx = 0;
coordy = 0;
active = 0;
turndirection = 0;
}


@end

and this is level.


#import "Level.h"
#import "Object.h"

@implementation Level

Object *myObj = [[Object alloc] init];
@end

Pretty basic at the moment but I've just started out. My problem is just after creating the new instance of Object I get an error saying "Initializer element is not constant".

What am I doing wrong here?
 
What am I doing wrong here?
You need to put the following line in a method within the Level class:
Code:
Object *myObj = [[Object alloc] init];

Or you can define it as static, like so:
Code:
static Object *myObj = [[Object alloc] init];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.