Cannot assign value of type '(String?, Bool, [AnyObject]?, NSError?) -> ()' to


After I update Xcode Version 8.0 (8A218a) swift 3, I got this error


Cannot assign value of type '(String?, Bool, [AnyObject]?, NSError?) -> ()' to type 'UIActivityViewControllerCompletionWithItemsHandler?'

</blockquote> activityview.completionWithItemsHandler = {(activityType: String?, completed:Bool, returnedItems:[AnyObject]?, error: NSError?) in if !completed { print("cancelled") return }else{ complele() } }

I have been following this <a href="https://stackoverflow.com/questions/32598745/cannot-assign-a-value-of-type-string-bool-anyobject-nserror-void-to" rel="nofollow">Cannot assign a value of type '(String!, Bool, [AnyObject]!, NSError!)->Void to a value of type UIActivityViewControllerCompletionWithItemsHandler?'</a>

But i still got the error message.

It works well in previous version 7.3.1 swift 2.


Use UIActivityType instead of String, [Any] instead of [AnyObject] and Error instead of NSError like this.

activityview.completionWithItemsHandler = {(activityType: UIActivityType?, completed:Bool, returnedItems:[Any]?, error: Error?) in if !completed { print("cancelled") return }else{ complele() } }

Check <a href="https://developer.apple.com/reference/uikit/uiactivityviewcontrollercompletionwithitemshandler" rel="nofollow">apple documentation</a> for more detail.


  • Create Outlook .ics file in C# with Hyperlink inside
  • MVC3 Data in model set to null when posting
  • CLLocationManager Coordinates
  • Cannot assign value of type '(String?, Bool, [AnyObject]?, NSError?) -> ()' to
  • Using KnockoutJS automatic binding
  • MySQL stops using index when additional constraints are added
  • Bootstrap Carousel showing all images at once when i use ng-repeat
  • Running interactive Bash commands over ssh
  • AFNetworking base64 parameter, characters being escaped by NSJSONSerialization
  • How do I observe a signal and immediately receive a `next` event if it has already occured?
  • Variable is not a static member of class
  • Why is my segue causing an “unrecognized selector sent to instance” NSInvalidArgumentException?
  • Facebook iOS SDK v4.0, get friends list
  • Swift Cast Generics Type
  • Error Domain=NSCocoaErrorDomain Code=3840 “Invalid value around character 0.” UserInfo={NSDebugDescr
  • Google App Indexing not resolving for Swift?
  • iOS 9 errors and correct conversion to swift 2
  • Generate a unique string based on a pair of strings
  • Deleting a widget from QTableView
  • multidatatrigger with multibinding in ControlTemplate.Triggers
  • Is there a parser equivalent of 'fragment' marking in ANTLR4?
  • How to access profile picture with Facebook API in Swift 3?
  • Build Successful but not running on simulator
  • How to set my toolbar fixed while scrolling android
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?