我有一个协议:
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'
我该如何解决?