[swift-corelibs-dev] A question about @NSCopying

Philippe Hausler phausler at apple.com
Fri Mar 18 15:25:02 CDT 2016


> On Mar 18, 2016, at 1:18 PM, Pushkar N Kulkarni via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
> 
> I am trying to implement some of the methods and properties in NSOrderedSet. 
> 
> The read-only property "reversedOrderedSet" has the @NSCopying attribute according to the NSOrderedSet class reference. 
> 
> So, I tried to do this: 
> @NSCopying public var reversedOrderedSet: NSOrderedSet {
> 
>     return NSOrderedSet.init(array: _orderedStorage.reverse())
> 
> }
> 
> 
> 

swift-corelibs-foundation can’t really implement that in terms of adopting the decorator of @NSCopying because it does not have objc backing.

> The compiler says "@NSCopying requires the property to be mutable". When inherited by NSMutableOrderedSet, doesn't this property qualify to be mutable? 
> 
> 
> 
The mutable state here is a setter not a NSMutableOrderedSet


> Does @NSCopying not apply here? Is my understanding of "mutable (stored) property" flawed? Or is there a problem with the implementation?
> 
> 
> 
just comment it out and you will be good to go likely.

> Nowhere in Foundation is @NSCopying being used currently. So don't have a "reference implementation" :)
> 
> 
> 
> 
> 
> Pushkar N Kulkarni,
> IBM Runtimes
> 
> Simplicity is prerequisite for reliability - Edsger W. Dijkstra
> 
> 
> _______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160318/a84ce7b8/attachment.html>


More information about the swift-corelibs-dev mailing list