Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
CloudPhotos (OS X).swift/CloudPhotos/AssetToImageTransformer.swift
/* |
Copyright (C) 2017 Apple Inc. All Rights Reserved. |
See LICENSE.txt for this sample’s licensing information |
Abstract: |
Value transformer to change a CKAsset to an image. |
*/ |
import Foundation |
// We use this value transformer to help us bind our table cell view's image to the CKAsset image. |
// |
class AssetToImageTransformer : ValueTransformer { |
func transformedValueClass() -> AnyClass { |
return NSImage.self |
} |
func allowsReverseTransformation() -> Bool { |
return false |
} |
override func transformedValue(_ value: Any?) -> Any? { |
// Update the photo. |
if value != nil { |
let photo = value as! CloudPhoto |
let imageData = photo.photoImage |
return imageData |
} |
return nil |
} |
} |
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-03-09