餘米試圖創建可以刪除物品,如下面的函數:從PFObject陣列刪除特定PFObject
var array = [23,36,12,45,52,63]
removeItem(12,array)
result : array = [23,36,45,52,63]
我米試圖實現這種對PFObject但我爲得到錯誤:
public func removeObjectFromArray(user:PFObject,array:[PFObject]) -> [PFObject]{
for var i = 0;i < array.count ; i++ {
if array[i].objectId == user.objectId{
array.removeAtIndex(i)
return array
}
}
}
那我米得到的錯誤:
Immutable type of [PFObject] only ha mutating members named 'removeAtIndex'
的任何解決方案呢?
謝謝
的NSMutableArray提供此https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/#//apple_ref/occ/instm/NSMutableArray/removeObjectsInArray: – danh