What Objective-C datatype would you recommend to store the following:
Position – The position for an object on the screen
Direction – The direction of the object
Velocity – Well, the velocity of the object
Bounds – The allowed bounds for where the object is allowed to be.
Thanks!
Björn
Objective-C is a superset of C. For these sort of things you would normally use C structs, though you might alternatively make them fields of an object.
If your question is actually about predefined types in Cocoa, then there are options depending on the particular version (ie, platform — Mac OS, iOS or I guess conceivably GNUStep) and particular purpose.
For basic 2D stuff, the simplest choice would probably be
CGPointfor position, direction and velocity (assuming velocity is a vector quantity distinct from direction; otherwise just use adouble) andCGRectfor bounds.(Arguably, it is a marginal semantic abuse to use
CGPointfor non-position vectors, but I see no reason to be that picky.)