patrickwong / photo-app

3 stars 0 forks source link

Optimize for PhotoKit #36

Open baiIey opened 9 years ago

baiIey commented 9 years ago

Hey all,

There are some references to [ALAssetsLibrary], which is deprecated, (https://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/) in EditPhotoViewController.swift. We should be taking advantage of iOS 8's Photo Framework.

This may be tied to some of the performance hits the app has taken lately.

For model updates, I may modify the block below, since it's currently crashing the app when a user hits Done.

    @IBAction func doneDidPress(sender: AnyObject) {
        let imageToSave = filter.outputImage
        let softwareContext = CIContext(options:[kCIContextUseSoftwareRenderer: true])
        let cgimg = softwareContext.createCGImage(imageToSave, fromRect:imageToSave.extent())
        let library = ALAssetsLibrary()
        library.writeImageToSavedPhotosAlbum(cgimg,
            metadata:imageToSave.properties(),
            completionBlock:nil)
        dismissViewControllerAnimated(true, completion: nil)
    }

/cc @patrickwong @nbories-okta