I'm wrapping CLLocationManager (and its delegate), and I'm trying to create a 
protocol like this. This is directly cribbed from CLLocationManagerDelegate.

---------------
public
protocol
LZLocationManagerDelegate : NSObjectProtocol
{
    optional public func locationManager(manager: LZLocationManager, 
didUpdateLocations locations: [CLLocation])
}
---------------

But I get these errors:

LZLocationManager.swift:16:5: 'optional' can only be applied to members of an 
@objc protocol
LZLocationManager.swift:70:41: Cannot use optional chaining on non-optional 
value of type '(LZLocationManager, didUpdateLocations: [CLLocation]) -> ()'

Apple's version compiles flawlessly (comments removed):

---------------
public protocol CLLocationManagerDelegate : NSObjectProtocol {
    @available(iOS 6.0, *)
    optional public func locationManager(manager: CLLocationManager, 
didUpdateLocations locations: [CLLocation])

    // ...remainder removed for brevity
}
---------------

Adding @objc fixes it, but I would have thought NSObjectProtocol implied that. 
Also, when I look at the Apple Swift exports, it's not there (is that a 
limitation of the exported view?).

-- 
Rick Mann
rm...@latencyzero.com


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

Reply via email to