xcode:属性“title”“copy”属性与超类“UIViewController”属性不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4653718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:04:34  来源:igfitidea点击:

xcode: property 'title' 'copy' attribute does not match super class 'UIViewController' property

iphonexcodecompilationwarnings

提问by Pavan

Hi I'm currently getting this error message. and by the love of banana, I cannot figure out what I am not doing right.

您好,我目前收到此错误消息。由于对香蕉的热爱,我无法弄清楚我做错了什么。

Its just an

它只是一个

IBOutlet UILabel *title;

and

@property(nonatomic, retain) IBOutlet UILabel *title;

I've made which is connected to my xib file connected to a UILabel because I dynamically change the title during run time.

我已经将它连接到连接到 UILabel 的 xib 文件,因为我在运行时动态更改了标题。

Classes/../taskViewController.h:44: warning: property 'title' 'copy' attribute does not match super class 'UIViewController' property

Classes/../taskViewController.h:44: 警告:属性“title”“copy”属性与超类“UIViewController”属性不匹配

I dont understand what it means. Normally i am able to get rid of warning messages. But this one... I dont have a clue whats going on.

我不明白这是什么意思。通常我能够摆脱警告消息。但是这个……我不知道发生了什么。

Can someone please guide me and explain what is happening here.

有人可以指导我并解释这里发生的事情。

回答by ughoavgfhw

Your problem is that UIViewController already defines a title property and you are using a different memory manangement option than it does. To fix this, change the name of your property. ex: @property (nonatomic, copy) UILabel *titleLabel;. If you want the instance variable to have the same name, and you use @synthesize, use @synthesize titleLabel=title;.

您的问题是 UIViewController 已经定义了一个 title 属性,并且您使用的内存管理选项与它不同。要解决此问题,请更改您的资产名称。例如:@property (nonatomic, copy) UILabel *titleLabel;。如果您希望实例变量具有相同的名称,并且您使用 @synthesize,请使用@synthesize titleLabel=title;.

As an aside, why are you copying a UILabel? Normally you would use retain so that it is the same object.

顺便说一句,你为什么要复制 UILabel?通常您会使用保留,以便它是同一个对象。

回答by David Gelhar

It means:

它的意思是:

  • you have a subclass of UIViewController
  • it contains a property named "title"
  • you have declared the property with the "copy" attribute
  • the parent class (UIViewController) already has "title" property with a conflicting definition (i.e., not "copy")
  • 你有一个 UIViewController 的子类
  • 它包含一个名为“title”的属性
  • 您已使用“复制”属性声明了该属性
  • 父类 (UIViewController) 已经具有具有冲突定义的“title”属性(即,不是“copy”)

回答by Robin

Well i want to just clarify that title is a predefined object in the UIViewController so you cannot create your own objects with that same name, change the with some thing else and see that it wont give you that error.

好吧,我只想澄清一下,标题是 UIViewController 中的一个预定义对象,因此您无法创建自己的具有相同名称的对象,使用其他内容更改它并查看它不会给您那个错误。