迅速。类型不符合协议。类型和协议是相同的

时间:2016-07-26 18:08:30

标签: ios swift protocols

我有一个协议:

protocol InnerObject
{
   init(record : NSManagedObject)
   init(pfObject : PFObject)
   func saveToRecord(aRecord: NSManagedObject)
   func toPFObject() -> PFObject
}

我有一个数组的扩展名:

extension Array where Element : InnerObject
{
    func pfObjects() -> [PFObject]
   {
       var pfObjects : [PFObject] = []

       for innerObject in self
       {
           let pfObject : PFObject = innerObject.toPFObject()
           pfObjects.append(pfObject)
       }

       return pfObjects
   }
}

我正在尝试使用它:

func saveObjects(aObjects : [InnerObject], withCompletion aCompletion : () -> (Bool, NSError))
{
    let array : [PFObject] = aObjects.pfObjects() // the error is here
}

但它会产生错误:

Type 'InnerObject' does not conform to protocol 'InnerObject'

我该如何解决?

0 个答案:

没有答案