我的<table>
<thead>
<tr>
<td>Overall</td>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td>Question 1</td>
<td width="300px">
<div class="scale-text">No Rating</div>
<div data-scale="1" class="scale scale-1"></div>
<div data-scale="2" class="scale scale-2"></div>
<div data-scale="3" class="scale scale-3"></div>
<div data-scale="4" class="scale scale-4"></div>
<div data-scale="5" class="scale scale-5"></div>
</td>
<td>Comment</td>
</tr>
<tr>
<td>Question 1</td>
<td width="300px">
<div class="scale-text">No Rating</div>
<div data-scale="1" class="scale scale-1"></div>
<div data-scale="2" class="scale scale-2"></div>
<div data-scale="3" class="scale scale-3"></div>
<div data-scale="4" class="scale scale-4"></div>
<div data-scale="5" class="scale scale-5"></div>
</td>
<td>Comment</td>
</tr>
<tr>
<td>Question 1</td>
<td width="300px">
<div class="scale-text">No Rating</div>
<div data-scale="1" class="scale scale-1"></div>
<div data-scale="2" class="scale scale-2"></div>
<div data-scale="3" class="scale scale-3"></div>
<div data-scale="4" class="scale scale-4"></div>
<div data-scale="5" class="scale scale-5"></div>
</td>
<td>Comment</td>
</tr>
<tr>
<td>Question 1</td>
<td width="300px">
<div class="scale-text">No Rating</div>
<div data-scale="1" class="scale scale-1"></div>
<div data-scale="2" class="scale scale-2"></div>
<div data-scale="3" class="scale scale-3"></div>
<div data-scale="4" class="scale scale-4"></div>
<div data-scale="5" class="scale scale-5"></div>
</td>
<td>Comment</td>
</tr>
课程中有一个属性,其中NSManagedObject
用作某种标记。默认值为Int
,此对象是我的表视图的源。属性0
不必须是tag
变量。
@NSManaged
我已经实现了一种通过拖动来复制单元格的方法:
let data: [Items] = []
这显然不会起作用,因为let newItem = data[indexPath.row]
newItem.tag++
let newPath = NSIndexPath(forRow: indexPath.row + 1, inSection: indexPath.section)
data.insert(newItem, atIndex: newPath.row)
tableView.insertRowsAtIndexPaths([newPath], withRowAnimation: .Fade)
也会在原始项目中更改。我可以通过将tag
包装在结构中或使用元组来解决此问题。但我希望我可以避免这种情况,并以某种方式找到另一种(更优雅的方式)这样做。有什么想法吗?
编辑:
我忘了提及,我不想创建一个新的类实例。