Question

In my project I'm using coredata. One of the entity has an attribute named newTotal, in its corresponding NSManagedObject class the property declaration is like

@property (nonatomic, strong) NSString *newTotal;

If I add a property like this in an NSObject subclass the XCode will show an error like

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

But in NSManaged object subclasses it's not showing the error but the application crashes when the property is accessed, something saying like EXC_BAD_ACCESS.

Why XCode not showing error but application crashes?. Is this a bug with XCode/clang/LLVM ?

I know its something related to the synthesize. NSManagedObject sub classes not synthesizing the property in it, but the @dynamic directive just tells the compiler that the getter and setter methods are implemented not by the class itself but somewhere else (like the superclass or will be provided at runtime). But I have no clear Idea about this. Can anybody can give a clear idea about the problem?

Was it helpful?

Solution

I can see you are using ARC.

In ARC memory is managed for you, but there are few things you can/have to do yourself. You cannot name property "newXxxx" because:

https://developer.apple.com/library/mac/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

You cannot give an accessor a name that begins with new. This in turn means that you can’t, for example, declare a property whose name begins with new unless you specify a different getter:

// Won't work:

@property NSString *newTitle;

// Works:

@property (getter=theNewTitle) NSString *newTitle;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top