A question about @NSCopying


(Pushkar N Kulkarni) #1

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())

}

The compiler says “@NSCopying requires the property to be mutable”. When inherited by NSMutableOrderedSet, doesn’t this property qualify to be mutable?

Does @NSCopying not apply here? Is my understanding of “mutable (stored) property” flawed? Or is there a problem with the implementation?

Nowhere in Foundation is @NSCopying being used currently. So don’t have a “reference implementation” :slight_smile:

Pushkar N Kulkarni,

IBM Runtimes

Simplicity is prerequisite for reliability - Edsger W. Dijkstra


(Philippe Hausler) #2

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.

···

On Mar 18, 2016, at 1:18 PM, Pushkar N Kulkarni via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

Nowhere in Foundation is @NSCopying being used currently. So don't have a "reference implementation" :slight_smile:

Pushkar N Kulkarni,
IBM Runtimes

Simplicity is prerequisite for reliability - Edsger W. Dijkstra

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev