-1
我想将一些Objective-C代码迁移到我的Swift代码,但在Swift中存在一些协议错误。在我的Objective-C中,所有工作都很完美。可以;定义和使用协议
我有一类说MGCDayPlannerEKViewController,
public class MGCDayPlannerEKViewController : MGCDayPlannerViewController, UIPopoverPresentationControllerDelegate {
public var calendar: NSCalendar!
public var visibleCalendars: Set<NSObject>!
public var eventStore: EKEventStore! { get }
weak public var delegate: MGCDayPlannerEKViewControllerDelegate!
/** designated initializer */
public init!(eventStore: EKEventStore!)
public func reloadEvents()
}
public protocol MGCDayPlannerEKViewControllerDelegate : NSObjectProtocol {
@available(iOS 4.0, *)
optional public func dayPlannerEKEViewController(vc: MGCDayPlannerEKViewController!, willPresentEventViewController eventViewController: EKEventViewController!)
@available(iOS 4.0, *)
optional public func dayPlannerEKViewController(vc: MGCDayPlannerEKViewController!, navigationControllerForPresentingEventViewController eventViewController: EKEventViewController!) -> UINavigationController!
}
在我的雨燕类,我继承这个类,并创建我的新类
protocol WeekViewControllerDelegate :MGCDayPlannerEKViewControllerDelegate,CalendarViewControllerDelegate,UIViewControllerTransitioningDelegate {
}
class WeekViewController: MGCDayPlannerEKViewController {
var delegate: WeekViewControllerDelegate?
var showDimmedTimeRanges = false
var isiPad : Bool {
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
return true
}else{
return false
}
}
}
内一个协议,但在这里,我得到错误在委托声明中。错误是
Property 'delegate' with type 'WeekViewControllerDelegate?' cannot override a property with type 'MGCDayPlannerEKViewControllerDelegate!' (aka 'ImplicitlyUnwrappedOptional<MGCDayPlannerEKViewControllerDelegate>')
我在做什么错?