10.4 C
London
Thursday, April 4, 2024

ios – Apple shared album asset native and cloud identifiers subject


Run getCloudID with the precise native identifier and this works to return cloud identifier which I retailer for later use. I run the getLocalID operate and get error message stating “Can’t convert worth of sort ‘String’ to anticipated aspect sort ‘Array.ArrayLiteralElement’ (aka ‘PHCloudIdentifier’)”.

Passing in ONLY string for native and cloud identifiers and undecided what the message means as doc from apple says it ought to work for the getLocalID operate.

func getCloudID(localIdentifiers: String) -> String {
    var cloudIdentifiers = String()
    let library = PHPhotoLibrary.shared()
    let iCloudIDs = library.cloudIdentifierMappings(forLocalIdentifiers: [localIdentifiers])
    for aCloudID in iCloudIDs {

        let cloudResult: End result = aCloudID.worth
        swap cloudResult {
            case .success(let success):
                let newValue = success.stringValue
                cloudIdentifiers.append(newValue)
        case .failure(let failure) :
            let thisError = failure as? PHPhotosError
            swap thisError?.code {
                case .identifierNotFound:
                    print("Failed to search out the cloud identifier for (aCloudID). (String(describing: thisError?.localizedDescription)))")
                default:
                    print("Error wanting up the cloud identifier for (aCloudID). (String(describing: thisError?.localizedDescription))")
            }
        }
    }
    return cloudIdentifiers
}

func getCloudID(cloudIdentifiers: String) -> String {
    var localIdentifiers = String()
    let library = PHPhotoLibrary.shared()
    let localIDs = library.localIdentifierMappings(for: [cloudIdentifiers])
    for aLocalID in localIDs {
        let localResult: End result = aLocalID.worth
        swap localResult {
            case .success(let success):
            localIdentifiers.append(success)
            print(localIdentifiers)
            case .failure(let failure) :
                let thisError = failure as? PHPhotosError
                swap thisError?.code {
                    case .identifierNotFound:
                        print("Failed to search out the native identifier for (aLocalID). (String(describing: thisError?.localizedDescription)))")
                    default:
                        print("Error wanting up the native identifier for (aLocalID). (String(describing: thisError?.localizedDescription))")
                }
          }
        }
    return localIdentifiers
}

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here