Exemple #1
0
    public void Can_set_and_retrieve_asset_by_key()
    {
        var record   = new CKRecord("record_type");
        var asset    = new CKAsset(NSURL.URLWithString("file:///someasset.bytes"));
        var assetKey = "asset_key";

        record.SetAsset(asset, assetKey);

        Assert.AreEqual(record.AssetForKey(assetKey), asset);
    }
    private void OnRecordSaved(CKRecord record, NSError error)
    {
        if (error != null)
        {
            Debug.LogError(error.LocalizedDescription);
        }
        else
        {
            Debug.Log(string.Format("Record saved with name: {0}", record.RecordID.RecordName));
            // Once saved, the FileURL may (but may not) point to a URL with the
            // asset contents. It may still point to the local filesys
            // See: https://developer.apple.com/documentation/cloudkit/ckasset/1515050-fileurl?language=objc

            CKAsset asset = record.AssetForKey("MyAsset");
            Debug.Log("Asset data is now at: " + asset.FileURL.AbsoluteString);
            StartCoroutine(GetRequest(asset.FileURL.AbsoluteString));
        }
    }