Thursday, 15 April 2010

objective c - Property name starting with 'new' prefix leads to BAD_ACCESS error in iOS -



objective c - Property name starting with 'new' prefix leads to BAD_ACCESS error in iOS -

my property declared in nsmanagedobject class name "newprice", leads "zombie object". after hours of debugging figured out there problem method releasing object not retaining it. after renaming property "pricenew" goes well. don't understand why causing problem.

declaration of property:

@property (nonatomic, retain) nsnumber * newprice;

this phone call causing problem:

[self setpiecestatewithprice:self.action.newprice];

after passing renamed argument self.action.pricenew goes well...

don't that.

in objective-c naming conventions, methods names begin new expected homecoming retained object. arc, naming convention becomes requirement. means normal, arc-compiled method should never start name new because compiler assume has retain count of 1.

to quote docs:

you own object create

you create object using method name begins “alloc”, “new”, “copy”, or “mutablecopy” (for example, alloc, newobject, or mutablecopy).

ios objective-c cocoa-touch

No comments:

Post a Comment