我有一个应用程序,用户拍照后,应该将照片保存到UserDefaults
中。但是我一直收到这个错误:
"cannot invoke 'setObject' with an argument list of type '(UIImage. type, forKey:[UIImage])'"
我已经查阅了文档和相关帖子,但是没有找到解决办法。这是我的代码。
let defaults = NSUserDefaults.standardUserDefaults()
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
picker.dismissViewControllerAnimated(true, completion: nil)
switch currentClothesSelection!{
case "1":
shirts.append(info[UIImagePickerControllerOriginalImage] as! UIImage)
//this is where the error occurs
defaults.setObject(UIImage.self, forKey: array1)
case "2" :
pants.append(info[UIImagePickerControllerOriginalImage] as! UIImage)
case "3" :
shorts.append(info[UIImagePickerControllerOriginalImage] as! UIImage)
case "4" :
jackets.append(info[UIImagePickerControllerOriginalImage] as! UIImage)
case "5" :
shoes.append(info[UIImagePickerControllerOriginalImage] as! UIImage)
default:
break
}