开发者

Getting a CGFloat instance variable from another class implementation

开发者 https://www.devze.com 2023-03-21 11:22 出处:网络
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.

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

精彩评论

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