Aggressor Aggressor - 9 months ago 121
Swift Question

UIImageWriteToSavedPhotosAlbum Selector Syntax Issue

Trying hard to get UIImageWriteToSavedPhotosAlbum to work in swift

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<()>)

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

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.



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.