I have an objective c class A that owns a c++ class B that has a velocity attribute.
Is it ok to use
@property(nonatomic) float velocity;
in class A even if that class does not have an velocity attribute. When I implement the
velocity function I will ask B and return that value, so it’s kind of an implicit attribute of class A.
I guess it works, so my question is if it is good practice.
Absolutely fine. Assuming that you have implemented the getter and setter correctly there is no requirement that a class with a property have a member variable at all!
Though you might run into problems with KVO – this property isn’t KVO compliant. That’s almost certainly not a problem though 🙂