Storing objects in an array in objective c -


After

I am trying to store 25 items in an array

  ( integer IY = 0; IY & LT; 5; IY ++) for (int ix = 0; i & LT; 5; i ++) {TerrainHex * myObject = [{[TerrainHex alloc] initWithName: (@ "grassHex Example 10000 ") Width: mGameWidth height: mGameHeight indexX: Ix index: iy]; MyObject.myImage.y + = 100; [Terrain hexarered object: myobacter]; [Self Combined: (id) myObject.myImage]; }} NSLog (@ "Terrean Array:% U", [Terrain Hex count]);   

The log is coming back in the form of zero though

I have in the H file

  @property NSMutableArray * TerrainHexArray   

and in the .m file ..

  @synthesize TerrainHexArray;   

I just tried that which someone tips below ..

  NSMutableArray * TerrainHexArray = [[NSMutableArray] alloc] init ];   

But this is just telling me the expected identifier of a warning.

After

It is certain that when you are adding addObject and NSLog TerrainHexArray does not exist, you say That someone has suggested that you tried to add alloc / init, which indicates that you do not understand object management in Objective-C.

I suggested that you go back, find a book on purpose-C

Incidentally, this is standard C ++ / Objective-coding practice (except for Microsoft ), Before and before you try any more coding, read at least a few chapters (through discussion of alloc / init et al). ) For example, to use the identifier with a leading lower case character, the leading caps reserve for type / class names.

Comments