Cloud Kit在Swift 2.0中执行了Query

时间:2015-07-21 20:05:46

标签: ios swift cloudkit

您好。 我正在尝试制作基于云套件的应用。对于使用此

的数据提取我
privateDatabase.performQuery(query, inZoneWithID: nil) {
        results, error in
        if error != nil {
            print(error)
        } else {
            print(results)
            for item in results {
                self.workoutData.append(item as! CKRecord)
            }
        }
    }

但是XCode说

  

' [CKRecord]&#39?;没有名为' Generator'

的成员

你能帮我吗?

1 个答案:

答案 0 :(得分:1)

您需要打开CKRecord数组,如下所示:

public static boolean allRowSumsEqual(int[][] m){
    if(m == null) return true;
    if(m.length == 0) return true;

    boolean a = false;
    int x = 0;
    int total = rowSum(m[0]);

    for (int i = 1; i < m.length; i++){
        // You can use your own function instead of the inner for loop
        x = rowSum(m[i]);
        if (x != total) {
           a = false;
           break;
        } else {
           x = 0; 
           a = true;
        }   
    }
    return a;
}

public static int rowSum(int[] v){
    int vSum = 0;

    // Assume a null row has sum 0
    if(v == null) return 0;

    for (int i = 0 ; i < v.length ; i++){
        vSum += v[i];
    }   
    return vSum;
}