开发者

Getting a CGFloat instance variable from another class implementation

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜