error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects

出现这种情况,主要是属性名中包含  关键字.

You can solve this by:

  1. Renaming that property:

    @property (strong, nonatomic) NSString *theNewTitle;
    
  2. Keeping the property name and specifying a getter name that doesn’t begin with one of the special method name prefixes:
    @property (strong, nonatomic, getter=theNewTitle) NSString *newTitle;
    
  3. Keeping both the property name and the getter name, and telling the compiler that, even though the getter name starts with new,
    it belongs to the none method
    family as opposed to the newmethod
    family:

    #ifndef __has_attribute
    #define __has_attribute(x) 0  // Compatibility with non-clang compilers
    #endif
    
    #if __has_attribute(objc_method_family)
    #define BV_OBJC_METHOD_FAMILY_NONE __attribute__((objc_method_family(none)))
    #else
    #define BV_OBJC_METHOD_FAMILY_NONE
    #endif
    
    @interface ViewController : UIViewController
    @property (strong, nonatomic) NSString *newTitle;
    - (NSString *)newTitle BV_OBJC_METHOD_FAMILY_NONE;
    @end
    

    Note that even though this solution allows you to keep newTitle as
    both the property name and the getter name, having a method called -newTitle that
    doesn’t return an object owned by the caller can be confusing for other people reading your code.

error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects,布布扣,bubuko.com

error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects

时间: 2024-08-05 15:21:06

error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects的相关文章

error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects I

error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects In file included from /Users/developer/Documents/StarShow/ShowWall/View/NewShowItemView.m:9: /Users/developer/Documents/StarShow/ShowWall/View/NewShowI

Error解决:Property's synthesized getter follows Cocoa naming convention for returning 'owned'

在项目中定义了以new开头的textField,结果报错: 先看我的源码: #import <UIKit/UIKit.h> @interface ResetPasswordViewController : UIViewController @property (weak, nonatomic) IBOutlet UITextField *phoneTextField; @property (weak, nonatomic) IBOutlet UITextField *oldPasswordTe

编译错误Property&#39;s synthesized getter follows Cocoa naming convention for returning &#39;owned&#39; objectss

错误在于你的工程下的某一个类中的下面这行 @property (retain, nonatomic) NSString *newImage; 错误就是因为用了new这个关键字,所以说我把new改为news就好了 严格上来说,主要的错误原因是 声明属性时要遵循内存管理原则,即不要使用某些关键字 编译错误Property's synthesized getter follows Cocoa naming convention for returning 'owned' objectss

错误: Property&#39;s synthesized getter follows Cocoa naming convention for returning &#39;owned&#39;

今天遇到一个奇怪的问题,一开始用下面的代码定义一个全局变量: @property (strong, nonatomic) NSDictionary          *newHomeDataDictionary; 结果一直报错误: Property's synthesized getter follows Cocoa naming convention for returning 'owned',看了好久也找不出问题,后来该前面 new 单词,发现就可以了,这才发现是苹果禁止了所有已 new 关

小胖说事24-----property&#39;s synthesized getter follows Cocoa naming convention for returning &#39;owned&#39; objec

今天在给类的属性命名的时候,用了newValue,就给报错:property's synthesized getter follows Cocoa naming convention for returning 'owned' objects,一阵郁闷不知道咋回事,后来查了资料后,原来是命名规范的事情: You own any object you create You create an object using a method whose name begins with "alloc&q

[CSS] Reduce Ambiguity in Class Names using a Naming Convention

A solid naming convention makes it less likely to run into naming conflicts and helps establish a semantic pattern that is easier for a team to follow. In this lesson, I'm using a variation of the BEM (Block Element Model) naming convention. OOCSS an

黑马程序员——OC语言@property、@synthesized与id

一.@property @synthesize关键字 注意:这两个关键字是编译器特性,让xcode可以自动生成getter和setter的声明和实现. (一)@property 关键字 @property 关键字可以自动生成某个成员变量的setter和getter方法的声明 @property int age; 编译时遇到这一行,则自动扩展成下面两句: - (void)setAge:(int)age; - (int)age; (二)@synthesize关键字 @synthesize关键字帮助生

ARC

ARC是什么 ARC是iOS 5推出的新功能,全称叫 ARC(Automatic Reference Counting).简单地说,就是代码中自动加入了retain/release,原先需要手动添加的用来处理内存管理的引用计数的代码可以自动地由编译器完成了. 该机能在 iOS 5/ Mac OS X 10.7 开始导入,利用 Xcode4.2 可以使用该机能.简单地理解ARC,就是通过指定的语法,让编译器(LLVM 3.0)在编译代码时,自动生成实例的引用计数管理部分代码.有一点,ARC并不是G

iOS应用开发:什么是ARC?

ARC是iOS 5推出的新功能,全称叫 ARC(Automatic Reference Counting).简单地说,就是代码中自动加入了retain/release,原先需要手动添加的用来处理内存管理的引用计数的代码可以自动地由编译器完成了. ARC是什么 变化点 使用ARC的好处 不好的地方 ARC基本规则 Objective-C对象 引用关键字 总结 新年伊始,万象更新.新一年开始,我们来更加深入了解一下iPhone开发的内部.作为开始,我们先来了解一下ARC. ARC是什么 ARC是iO