私はObjective Cが初めてで、この概念に混乱しています。
次のメソッドは、パラメーターとして渡されるクラスのインスタンスを作成し、インスタンスの変数を編集することになっています。
- (void) createObject:(Class)objecttype atPoint: (CGPoint)position {
if ([objecttype isSubclassOfClass:[GameObject class]]){
id theobject = [[objecttype alloc] init];
theobject.x = position.x; //error
theobject.y = position.y; //error
}
}
上記のエラー メッセージが表示されます。 Property 'x' not found on object of type '__strong id'
単純なように思えますが、何が悪いのかわかりません。