[英]Cannot assign a value of type '(String!, Bool, [AnyObject]!, NSError!)->Void to a value of type UIActivityViewControllerCompletionWithItemsHandler?'
I have the following lines of code in my project... 我的项目中有以下几行代码......
@IBAction func shareMeme(sender: UIBarButtonItem) {
let newMeme = save()
let memedImage = newMeme.memedImage
let activityViewController = UIActivityViewController(activityItems: [memedImage], applicationActivities: nil)
presentViewController(activityViewController, animated: true, completion: nil)
activityViewController.completionWithItemsHandler = {(type: String!, completed: Bool, returnedItems: [AnyObject]!, error: NSError!) -> Void in
dispatch_async(dispatch_get_main_queue()){
self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
}
}
}
I keep getting a compiler error "Cannot assign a value of type '(String!, Bool, [AnyObject]!, NSError!) -> Void' to a value of type 'UIActivityViewControllerCompletionWithItemsHandler?'" referring to the following line of code... 我不断收到编译器错误“无法将类型的值'(String!,Bool,[AnyObject] !, NSError!) - > Void'赋值为'UIActivityViewControllerCompletionWithItemsHandler?'”,参考以下代码行。 ..
activityViewController.completionWithItemsHandler = {(type: String!, completed: Bool, returnedItems: [AnyObject]!, error: NSError!) -> Void in
Any suggestions would be appreciated. 任何建议,将不胜感激。
Your type signature doesn't match the definition of UIActivityViewControllerCompletionWithItemsHandler
, which is (String?, Bool, [AnyObject]?, NSError?) -> Void
. 你的类型签名与
UIActivityViewControllerCompletionWithItemsHandler
的定义不匹配,它是(String?, Bool, [AnyObject]?, NSError?) -> Void
。 Replace your !
替换你的
!
s with ?
用
?
s and it should work fine. s它应该工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.