错误:属性'myBoolVariableName“与”保留“属性必须是对象类型 [英] error: property 'myBoolVariableName' with 'retain' attribute must be of object type

查看:217
本文介绍了错误:属性'myBoolVariableName“与”保留“属性必须是对象类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的.h文件我@interface定义范围内的BOOL值。在这里它是下面。它具有相同的问题,它是否是一个指针或没有。

I have a BOOL value inside my @interface definition in my .h file. Here it is below. It has the same problem whether it's a pointer or not.

@interface myCustomViewController : UIViewController <UIWebViewDelegate> {
{
 //...more iboutlets defined above
 BOOL *myBoolVariableName;
}

当我编译,我得到错误:财产myBoolVariableName与保留属性必须是对象类型的关于我的.h文件的导入行

When I compile, I get "error: property 'myBoolVariableName' with 'retain' attribute must be of object type" on the line for the import of my .h file.

我在这里找到了这个网页约一个整数/ NSNumber的:

I found this page here about an integer / nsnumber:

<一个href=\"http://discussions.apple.com/thread.jspa?threadID=1846927\">http://discussions.apple.com/thread.jspa?threadID=1846927

所以,似乎我不能使用@interface定义内布尔值。我可以用呢?

So, it seems I can't use BOOL values inside an @interface definition. What can I use instead?

我应该为BOOL /布尔值吗?

What should I do for BOOL / boolean values?

推荐答案

我猜,在你以后的界面,你有这样的事情:

I'm guessing that later in your interface you have something like this:

@property (retain) BOOL *myBoolVariableName;

这意味着使属性谁的值是一个指向一个BOOL,并使用保留的语义。

That means make a property who's value is a pointer to a BOOL, and use retain semantics.

您的问题是,BOOL *是一个指向内存字节,而不是指向一个对象。和保留的东西,只适用于对象。

Your problem is that BOOL * is a pointer to a byte of memory, not a pointer to an object. And retain is something that applies only to objects.

下面是你如何可以使一个BOOL属性。

Here's how you can make a BOOL property.

@interface myCustomViewController : UIViewController <UIWebViewDelegate> {
    BOOL myBoolVariableName;
}

@property myBoolVariableName;

@end

重要的区别在于变量声明为BOOL,而不是BOOL *和财产不具有(保留)。

The important differences are that the variable is declared as "BOOL", not "BOOL *" and the property doesn't have (retain).

这篇关于错误:属性'myBoolVariableName“与”保留“属性必须是对象类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆