如何将多张照片保存到数组和CoreData

时间:2017-08-15 11:31:24

标签: swift

此时用户可以制作照片或从图库中选择。下次我将它保存到阵列和核心。我怎么做,用户可以制作几张照片以及如何存储它?我明白,我可以为每个foto制作几个数组和几个按钮,但可能更漂亮吗?

// save
var imageArray: [Journal] = []  
let image = imageView.image
        let imageData = NSData(data: UIImageJPEGRepresentation(image!, 1.0)!)
        journal.imageCore = imageData
 (UIApplication.shared.delegate as! AppDelegate).saveContext()

// read
let foto = self.image.viewWithTag(5000) as! UIImageView
let data = UIImage(data:imageArray[LineForFullDetailLink].imageCore as! Data) 
foto.image = data 

// UIImagePicker
    func chooseImagePickerAction(source: UIImagePickerControllerSourceType)
        {
            if UIImagePickerController.isSourceTypeAvailable(source)
            {
                let imagePicker = UIImagePickerController()
                imagePicker.delegate = self
                imagePicker.allowsEditing = true
                imagePicker.sourceType = source
                self.present(imagePicker, animated: true, completion: nil)
            }
        }

0 个答案:

没有答案