'type'不是'T'的成员类型

时间:2015-07-31 23:22:37

标签: ios swift generics

声明时出现编译器错误:type: T.type

  

'type'不是'T'的成员类型

public class ParseRealmSync {

    public static func synchronize <T: Model> (type: T.type){
        var allObjects = [type]()
        var limit = 0
        var skip = 0
        var query = PFQuery(className: T.parseClassName(), predicate: nil)
        query.limit = limit
        query.skip = skip

        query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
            println(objects)
        }
    }
}

为什么?

1 个答案:

答案 0 :(得分:3)

应该是T.Type而不是T.type

另外

var allObjects: [T] = []

而不是

var allObjects = [type]()