[swift-users] CNLabeledValue var
laullon at gmail.com
Wed Jan 11 04:05:48 CST 2017
var toExcludeOrCopy : AnyObject?
Could help me on some cases...
But if I try this:
var props = [AnyObject]()
props += contact.phoneNumbers
( "contact" is as CNContact, so "contact.phoneNumbers" is
I get this error:
/Users/laullon/xcode/bipo/BiPo/MergePreview.swift:82:21: Cannot convert
value of type '[AnyObject]' to expected argument type 'inout _'
I get this error:
argument label 'contentsOf:' in call
On Tue, Jan 10, 2017 at 12:36 AM, Hooman Mehr <hooman at mac.com> wrote:
> This is a side effect of ObjC lightweight generics being imported as Swift
> generics in Swift 3.0.
> Since there is no common superclass that satisfies NSCopying &
> NSSecureCoding and the fact that NSSecureCoding has static requirements
> means you can’t do it (at least without hacks such as extending NSObject to
> conform to both protocols or creating a wrapper class and creating a
> non-generic subclass of CNLabeledValue and using it instead).
> For now, you have to use
> var toExcludeOrCopy : AnyObject?
> This is worthy of a bug report and points to a serious issue: The
> “limitations” that result from importing ObjC lightweight generics as Swift
> generics. One possible solution can be implementation of “Enhanced
> On Jan 9, 2017, at 11:23 AM, German Laullon via swift-users <
> swift-users at swift.org> wrote:
> Hi All
> I just upgrade to Swift 3. After open and convert my codes I found lots of
> errors. One of them is about CNLabeledValue.
> With Swift 2.3, it works well with:
> var toExcludeOrCopy : CNLabeledValue?
> With Swift 3, it gives me the error message:
> Reference to generic type 'CNLabeledValue' requires arguments in <...>.
> After I fixed it with XCode, it changed to:
> var toExcludeOrCopy : CNLabeledValue<AnyObject>?
> However, Xcode gives me error message with this fix:
> Type 'AnyObject' does not conform to protocol 'NSCopying'.
> I know the error is because of the generic type but I don't know how to
> declare with CNLabeledValue. My purpose is to store any the CNLabeledValue
> including phone number, email, address etc to one var.
> Any help will be appreciate.
> Germán Laullón
> swift-users mailing list
> swift-users at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users