is forKey:fileSize considered accessing non-public API?
has your app been rejected at review stage due to this?
let resources = PHAssetResource.assetResources(for: asset)
if let resource = resources.first {
if let fileSize = resource.value(forKey: "fileSize") as? Int {
return fileSize
}
}
I want to be crystal clear about this.
WARNING Don’t use key-value-coding (KVC) APIs to access implementation details of Apple’s public classes.
It’s possible that such code may be caught by the app ingestion process. However, even if that’s not the case then there’s no guarantee that they’ll work as you expect. Such properties are implementation details and can change at any time. Moreover, they might have non-obvious restrictions. For example, they might not be safe to access from the context in which you’re accessing them, resulting in hard-to-debug data races.
I’m not an expert in PhotoKit but my understanding is that it does provide a mechanism to get at the raw bytes of the resource, and you can get the count from that. If that’s not sufficient for your requirement, I encourage you to file an enhancement request for the features that you need. And if you do file an ER, please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"