c++ - Objective-C appropriate use of autorelease? -
i'm learning objective-c , i'm trying write vector3d class.
in c++ or java function want implement this:
vector3d { vector3d crossproduct(vector3d in) { vector3d result; result = ... // maths involving classes variables , input vectors variables. return result; } }
now in objective-c can't return object, object pointer. appropriate place use autorelease (before returning?). enable me chain methods on vector3d class (since many methods return object itself) particularly inefficient compared manually allocating , releasing objects? there other commonly used patterns used return objects in objective-c?
example of operations i'd class:
vector3d * vector3d1 = [[vector3d alloc] init]; vector3d * vector3d2 = [[vector3d alloc] init]; vector3d * vector3d3 = [vector3d1 cross [ [vector3d2 normalize ] multiply 1.43f]];
thanks.
yes, appropriate usage of autorelease
, in fact people using code expect cross
, normalize
, , multiply
return autoreleased object.
Comments
Post a Comment