Error I got
error: property's synthesized getter follows Cocoa naming convention for returning 'owned' objects
/Users/.../ViewController.h:12:40:
note: property declared here
@property (nonatomic, retain)NSString *newString;
why can't I use new in the variable name at the beginning? (like newString
)
Declaring a property synthesizes two accessor (getter/setter) methods:
-(NSString*)newString;
-(void)setNewString:(NSString*)newString;
Objective-C has a naming convention for memory management that is enforced by the compiler. Methods that start with new
(also "alloc", "copy", "mutableCopy") are required to return an object that will be "owned" by the caller. See the documentation. The generated accessor method doesn't follow the rule.
This naming convention is already used in Objective-C. You will need to use something like just plain old myString
to make this work. It's a compiler thing - compilers are picky.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With