@@ -26,7 +26,7 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
2626 case . Authorized:
2727 return true
2828 case . NotDetermined:
29- database. requestAccessToEntityType ( type, completion: nil )
29+ self . database. requestAccessToEntityType ( type, completion: { _ , _ in } )
3030 return false
3131 case . Restricted:
3232 return false
@@ -37,7 +37,7 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
3737 alert. addAction ( UIAlertAction ( title: " No " , style: . Cancel, handler: nil ) )
3838 alert. addAction ( UIAlertAction ( title: " OK " , style: . Default, handler: {
3939 _ in
40- let url = NSURL ( string: UIApplicationOpenSettingsURLString)
40+ let url = NSURL ( string: UIApplicationOpenSettingsURLString) !
4141 UIApplication . sharedApplication ( ) . openURL ( url)
4242 } ) )
4343 self . presentViewController ( alert, animated: true , completion: nil )
@@ -105,7 +105,7 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
105105 return
106106 }
107107
108- let greg = NSCalendar ( calendarIdentifier: NSGregorianCalendar)
108+ let greg = NSCalendar ( calendarIdentifier: NSGregorianCalendar) !
109109 let comp = NSDateComponents ( )
110110 comp. year = 2015
111111 comp. month = 8
@@ -164,7 +164,7 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
164164 ev. addRecurrenceRule ( recur)
165165 ev. calendar = cal
166166 // need a start date and end date
167- let greg = NSCalendar ( calendarIdentifier: NSGregorianCalendar)
167+ let greg = NSCalendar ( calendarIdentifier: NSGregorianCalendar) !
168168 let comp = NSDateComponents ( )
169169 comp. year = 2015
170170 comp. month = 1
@@ -196,7 +196,7 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
196196 }
197197
198198 let d1 = NSDate ( ) // today
199- let greg = NSCalendar ( calendarIdentifier: NSGregorianCalendar)
199+ let greg = NSCalendar ( calendarIdentifier: NSGregorianCalendar) !
200200 let comp = NSDateComponents ( )
201201 comp. year = 1 // we're going to add 1 to the year
202202 let d2 = greg. dateByAddingComponents ( comp, toDate: d1, options: nil )
@@ -237,7 +237,7 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
237237
238238 let evc = EKEventViewController ( )
239239 evc. event = ev
240- evc. allowsEditing = true
240+ evc. allowsEditing = false
241241 // evc.delegate = self
242242 // in iOS 8 I see no serious reason to assign a delegate...
243243 // ...unless you want to know what the user did
@@ -251,9 +251,10 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
251251 nav. modalPresentationStyle = . Popover
252252 self . presentViewController ( nav, animated: true , completion: nil )
253253 if let pop = nav. popoverPresentationController {
254- let v = sender as UIView
255- pop. sourceView = v
256- pop. sourceRect = v. bounds
254+ if let v = sender as? UIView {
255+ pop. sourceView = v
256+ pop. sourceRect = v. bounds
257+ }
257258 }
258259 }
259260 }
@@ -266,7 +267,7 @@ class ViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDele
266267 self . dismissViewControllerAnimated ( true , completion: nil )
267268 } else {
268269 // user deleted, pop off nav stack
269- self . navigationController. popToViewController ( self , animated: true )
270+ self . navigationController! . popToViewController ( self , animated: true )
270271 }
271272 }
272273
0 commit comments