I feel a bit miffed at the moment, I done a few iPhone projects that use floats and ints etc and all is fine.
I now using OpenGL and GLFloat[] C arrays etc and it seems unless I make methods to set / get them it crashes on the device (not the simulator). Now as these are not setup as properties (I don't think c arrays can) it kind of makes sense. However the project has been working for months without them. It seems something in the code is wiping out anything float / ints to the point that the debugger can see an assigned value but accessing it crashes the phone.
As soon as I think I know something for this platform, something changes my mind lol.
The question is.
How do you properly declare and use float arrays (float[3]) and ints (I usually do these as properties) so that you can set and get them. Should you need to make your own methods to get a开发者_Python百科nd set them?
Properties work the same way with primatives as Objects, except they get assign
ed instead of retain
ed:
@property (nonatomic, assign) int someInt;
Sorry, got a little hasty there. C arrays are not supported with properties. You will have to roll your own getter/setter for C arrays. If you still want to have a property, you can use an NSArray of GLfloat
primatives.
精彩评论