【问题标题】:@property for Core Foundation variable核心基础变量的@property
【发布时间】:2012-02-05 14:15:18
【问题描述】:

在我的程序中,我使用自动引用计数来设置核心基础变量。对于我的@interface,我使用:

@property (nonatomic, assign) CGRect home;

在我的@implementation 中我使用:

@synthesize 主页;

我收到一条错误消息“属性类型'home”('struct CGRect')与 ivar 'home'('struct CGRect *)的类型不匹配。请告知,以便我可以保留 CGRect 变量的 getter 和 setter。

提前致谢。

【问题讨论】:

  • 除了@property 声明之外,您是否声明了一个名为 home 的 ivar?如果是这样,请在问题中包含该行代码。
  • CGRect 不是 CoreFoundation,它是 Core Graphics。只是说...

标签: iphone


【解决方案1】:

在你的界面中你必须有这样的东西:

@interface MyClass: NSObject {
    CGRect *home;
//         ^ here's your problem
}
@property (nonatomic, assign) CGRect home;
@end

CGRect *home 中删除星号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    • 1970-01-01
    相关资源
    最近更新 更多