UIImageWriteToSavedPhotos相册选择器语法问题 [英] UIImageWriteToSavedPhotosAlbum Selector Syntax Issue

查看:115
本文介绍了UIImageWriteToSavedPhotos相册选择器语法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

努力使UIImageWriteToSavedPhotosAlbum迅速运行

但是问题在于它会抛出带有无法识别的选择器的NSInvalidArgumentException:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'app.PhotoEditor<0x14a1e400> does not respond to selector 
saveImageComplete:::'

您能否建议我的语法出了什么问题以及如何正确指定此选择器?据我了解,每个:代表方法期望的1个参数,由于它具有3个参数,因此我给了3个.

谢谢!

解决方案

如果您的方法是Objective-C方法,则选择器将类似于"saveImageCompleteImage:err:context:".您需要记住,参数是Objective-C名称的一部分,因此"saveImageComplete:::"并未指定在Swift中可以称为saveImageComplete(image:UIImage,err:NSError,context:UnsafePointer<()>)的方法.

Trying hard to get UIImageWriteToSavedPhotosAlbum to work in swift https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/index.html#//apple_ref/c/func/UIImageWriteToSavedPhotosAlbum

The documentation is sadly ONLY in objective C.

Here is my code:

func saveImage()
{
  UIImageWriteToSavedPhotosAlbum(uiimage, self, "saveImageComplete:::", nil)
}

func saveImageComplete(image:UIImage,err:NSError,context:UnsafePointer<()>)
{
  loadLastPhotoIntoGalleryIcon()
}

But the problem is that it throws the NSInvalidArgumentException with an unrecognized selector:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'app.PhotoEditor<0x14a1e400> does not respond to selector 
saveImageComplete:::'

Can you advise what is wrong with my syntax and how I properly specific this selector? From what I understand, each : represents 1 argument the method expects and since it has 3 parameters I gave it 3 :'s.

Thanks!

解决方案

If your method were an Objective-C method, the selector would be something like "saveImageCompleteImage:err:context:". You need to remember that the parameters are part of the name in Objective-C, so "saveImageComplete:::" doesn't specify a method that could be called saveImageComplete(image:UIImage,err:NSError,context:UnsafePointer<()>) in Swift.

这篇关于UIImageWriteToSavedPhotos相册选择器语法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆