• 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
CALayer retain count problem when changing geometry
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CALayer retain count problem when changing geometry


  • Subject: CALayer retain count problem when changing geometry
  • From: "Pete Callaway" <email@hidden>
  • Date: Sun, 4 May 2008 13:36:58 +0100

Hi,

I'm having a problem with the retain count of CALayers. It seems that
when changing geometry related properties, such as bounds or position,
the retain count is decremented. Below is a simple example that
exhibits the problem. In the example, if changeName is called, the
retain count of the layer isn't touched, but if changePosition is
called, the retain count is decremented so far that the overridden
dealloc method is called.

I can hide the problem by turning on garbage collection, but that's
cheating. Does anyone have any ideas as to what might be causing this?

Cheers,
Pete

------------------------------------------------------------------------

@interface TestController : NSObject {
	IBOutlet NSView *view;
	TestLayer *_testLayer;
}

- (IBAction)changePosition:(id)sender;
- (IBAction)changeName:(id)sender;

@end

------------------------------------------------------------------------

@implementation TestController

- (void)awakeFromNib
{
	view.wantsLayer = YES;

	_testLayer = [[TestLayer alloc] init];
	_testLayer.name = @"layer1";
	[view.layer addSublayer:_testLayer];
}

- (void)dealloc
{
	[_testLayer release];
	[super dealloc];
}

- (IBAction)changePosition:(id)sender
{
	NSPoint newPosition = _testLayer.position;
	newPosition.x += 10;
	_testLayer.position = newPosition;
}

- (IBAction)changeName:(id)sender
{
	_testLayer.name = [_testLayer.name stringByAppendingString:@"1"];
}

@end

------------------------------------------------------------------------

@interface TestLayer : CATextLayer {
}

@end

------------------------------------------------------------------------

@implementation TestLayer

- (void)dealloc
{
	NSLog(@"TestLayer dealloc called");
	[super dealloc];
}

@end
_______________________________________________

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

  • Prev by Date: Re: Proxy Window of another
  • Next by Date: iPhone SDK Question
  • Previous by thread: Re: Working with svg
  • Next by thread: iPhone SDK Question
  • Index(es):
    • Date
    • Thread