properties attributes misunderstanding
properties attributes misunderstanding
- Subject: properties attributes misunderstanding
- From: Colin Howarth <email@hidden>
- Date: Wed, 30 Sep 2009 15:02:45 +0200
Hi,
I have a class
@interface Ray : NSObject {
...
NSBezierPath *path;
...
}
@property (copy) NSBezierPath *path;
@end
an instance of which is accessed in another class:
- (void)drawRect:(NSRect)rect
{
NSBezierPath *temporaryPathPointerWhichIsSupposedToBeDifferent;
...
temporaryPathPointerWhichIsSupposedToBeDifferent = [ray.path];
[temporaryPathPointerWhichIsSupposedToBeDifferent
transformUsingAffineTransform: aVeryLongDescriptiveTransformName];
[temporaryPathPointerWhichIsSupposedToBeDifferent stroke];
...
}
I thought the (copy) attribute would mean that
temporaryPathPointerWhichIsSupposedToBeDifferent would be, well, a
copy of the original path instance (which conforms to the NSCopying
protocol). Of course, the compiler doesn't care what *I* think should
happen, and applies the transform to path (which is identical to
temporaryPathPointerWhichIsSupposedToBeDifferent).
It works if I do:
temporaryPathPointerWhichIsSupposedToBeDifferent = [ray.path copy];
instead.
Why isn't it doing what I think it should do though?
Thanks,
colin
_______________________________________________
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