What's the alternative to constructing a slector from a string for properties that have not been exposed?
E.g. for getting the file name and file size of a PHAssetResource:
if resource.responds(to: Selector("originalFilename")) {
let fileName = resource.value(forKey: "originalFilename") as? String
NSLog("resource filename: %@", fileName ?? "<unknown>")
}
if resource.responds(to: Selector("fileSize")) {
let fileSize = resource.value(forKey: "fileSize") as? CLong
NSLog("resource fileSize: %d", fileSize ?? -1)
}
These two properties, originalFilename and fileSize, are defined in an internal subclass of PHAssetResource, PHInternalAssetResource.
Aucun commentaire:
Enregistrer un commentaire