I'm quite new to Objective C development and I was wondering how I could get a CGFloat value 开发者_开发百科out of an instance variable of a class in another class.
Let's say I've got a class A in which the CGFloat is an instance variable.
How can I in the implementation of class B get that CGFloat in class A ?
Thanks
Implement a getter in class A:
- (CGFloat)myFloat
{
return myFloat;
}
Or use a property (essentially the same thing, just less typing in most cases):
In ClassA.h:
@property (nonatomic, assign) CGFloat myFloat;
in ClassA.m:
@synthesize myFloat;
精彩评论