2015-04-03 55 views

回答

1

您必須創建一個新的NSIndexPath。如果你需要刪除一個特定的值,你必須在斯威夫特玩指針

let originalPath = NSIndexPath(indexes: [1,2,3], length: 3) 
var indexes = UnsafeMutablePointer<Int>.alloc(originalPath.length) 
originalPath.getIndexes(indexes) // This extracts values from NSIndexPath 

var newValues = Array<Int>() 
// Iterate over the pointer array 
for val in UnsafeBufferPointer(start: indexes, count: originalPath.length) { 
    // Determine values which you want in the new NSIndexPath 
    newValues.append(val) 
} 

let newPath = NSIndexPath(indexes: newValues, length: newValues.count) 
0

你真的沒有描述什麼,爲什麼你想這樣做,但

myIndexPath = myIndexPath.indexPathByRemovingLastIndex()