I have a custom class Manager in Xcode. This class spawns several instances of class Player on a timer, so every tick of the timer it will make a new instance. I would like to pass the instance of Manager to each instance of Player through Players init method:
-(id)initWithMngr:(UIImage *)image andManager:(Manager *)mngr
Here I get the error “expected a type.” with or without the asterisk. The Manager class is in the same project and everything but I don’t understand how to do this. I am very new to Objective C, thanks 🙂
You should add either
#import "Manager.h"or@class Manager;to your file, where interface ofPlayerclass is defined – possibly, “Player.h”. (Here I suppose that yourManagerclass interface is defined in “Manager.h” file andPlayer– in “Player.h”.)If you will choose variant with
@class Manager, don’t forget to add#import "Manager.h"to yourPlayer‘s implementation file (suppose, “Player.m”).