Re: Subclassing NSControl and inheritance of target, action properties
Re: Subclassing NSControl and inheritance of target, action properties
- Subject: Re: Subclassing NSControl and inheritance of target, action properties
- From: Graham Cox <email@hidden>
- Date: Fri, 30 Jan 2015 12:03:48 +1100
> On 30 Jan 2015, at 11:40 am, Roland King <email@hidden> wrote:
>
> I can get that warning too, but only if I explicitly declare the property 'nonatomic', like this
>
> @property (readwrite, nonatomic ) SEL action; // 'atomic' attribute on property 'action' does not match the property inherited from 'NSControl'
>
> if I declare them specifically atomic (which I thought was the default) then it stops whining. Error message could be more accurate as in 'nonatomic' attribute on ... etc.
OK, solved. I *was* including 'nonatomic', but I took that out. The warning remained - for a while. After several recompiles it suddenly removed itself. (Actually I've noticed Xcode is pretty slow to remove complaints and errors at times, particularly structural things such as missing or mismatched end braces when you edit a block of code and then fix up the end braces as needed - the warning comes up mid-edit before you've finished and then doesn't go away until several recompiles later. Maybe this is another example of Xcode being too quick to warn and too slow to realise its mistake.)
>> On 30 Jan 2015, at 11:38 am, Quincey Morris <email@hidden> wrote:
>>
>> The 10.10 SDK uses real @property declarations, but doesn’t specify atomicity, which means the property defaults to atomic. You said before that "the properties have to be nonatomic”. So you’re declaring them nonatomic? You can’t.
>>
>> Note that it makes no difference. On all existing Apple architectures, “atomic” properties of 8-byte quantities (or smaller) (including pointers) have no overhead, so atomic properties synthesize the same code as nonatomic properties. (Well, that’s what I recall Greg Parker saying, a few months ago.)
>
Regarding 'nonatomic', in previous times, I've had a different warning when I used @synthesize with an assigned ivar and the property was not 'nonatomic'. Maybe that's changed but as a result of it I got conditioned to always including nonatomic for my properties when I wanted to back them with an ivar. From what you're saying, that's not necessary (any more?) if so, it makes a lot of my property declarations wrong, or at least verbose. Why even have atomic/nonatomic if there's no difference, and if you're writing your own setters (a different but related issue), how can you make them atomic anyway?
--Graham
_______________________________________________
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