• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: __attribute__((NSObject)) not behaving as expected
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: __attribute__((NSObject)) not behaving as expected


  • Subject: Re: __attribute__((NSObject)) not behaving as expected
  • From: Manfred Schwind <email@hidden>
  • Date: Fri, 24 Jan 2014 20:10:59 +0100

Does ist help, if you assign it this way instead:

self.context = theContext;

In your original code you're directly accessing the "backed" instance variable instead of going over the property, so maybe your property-declaration is ignored in this case.

Regards,
Mani

Am 24.01.2014 um 19:58 schrieb Kevin Meaney <email@hidden>:

> Building on and compiling for minimum system of 10.9. Xcode 5.0.1
>
> Using ARC.
>
> I have a property declared so:
>
> 	@property (readonly, strong) __attribute__((NSObject)) CGContextRef context
>
> I have a designatied initializer defined like so:
>
> 	-(instancetype)initWithCGContext:(CGContextRef)theContext
>
> The object is alloc'd and the init method is called immediately after the context is created. Immediately after the init method returns the context is released.
>
> If in the implementation of the init method I have:
>
> 	self->_context = theContext
>
> Then the first time I try and access the context I get a memory access exception. If I replace that with:
>
> 	self->_context = CGContextRetain(theContext);
>
> Then I get a memory leak of the context when my object is destroyed.
>
> If however I just declare my property like so:
>
> 	@property (readonly) CGContextRef context;
>
> And in the initializer I use:
>
> 	self->_context = CGContextRetain(theContext);
>
> And add a dealloc:
>
> 	-(void)dealloc
> 	{
> 		CGContextRelease(self->_context);
> 	}
>
> Then everything works as desired.
>
> I'd like to know what I'm doing wrong.
>
> Kevin
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: __attribute__((NSObject)) not behaving as expected
      • From: Kevin Meaney <email@hidden>
References: 
 >__attribute__((NSObject)) not behaving as expected (From: Kevin Meaney <email@hidden>)

  • Prev by Date: Re: __attribute__((NSObject)) not behaving as expected
  • Next by Date: Re: __attribute__((NSObject)) not behaving as expected
  • Previous by thread: Re: __attribute__((NSObject)) not behaving as expected
  • Next by thread: Re: __attribute__((NSObject)) not behaving as expected
  • Index(es):
    • Date
    • Thread