我的OSX Swift项目中有一个简单的NSOutlineView
设置从一个基本数组中提供,但它导致EXC_BAD_ACCESS
崩溃。
启用僵尸后,它崩溃并出现以下错误:
[NSMutableIndexSet retain]: message sent to deallocated instance
Heeeelp!这是我的代码:
class SidebarViewController: NSViewController, NSOutlineViewDataSource {
//MARK: Vars
@IBOutlet var sidebar : NSOutlineView?
var data : [String] = ["Assemblies", "Parts", "Customers"]
//MARK: Init
override func viewDidLoad()
{
super.viewDidLoad()
// Do view setup here.
}
//MARK: NSOutlineView Delegate / Datasource
func outlineView(outlineView: NSOutlineView, numberOfChildrenOfItem item: AnyObject?) -> Int
{
return data.count
}
func outlineView(outlineView: NSOutlineView, isItemExpandable item: AnyObject) -> Bool
{
return false
}
func outlineView(outlineView: NSOutlineView, child index: Int, ofItem item: AnyObject?) -> AnyObject
{
return data[index]
}
func outlineView(outlineView: NSOutlineView, objectValueForTableColumn tableColumn: NSTableColumn?, byItem item: AnyObject?) -> AnyObject?
{
return item
}
}
答案 0 :(得分:0)
原来objectValueForTableColumn
方法需要返回obj_c
个对象。因此,在我的数组中返回String
不起作用。我将其更改为NSString
,现在可以使用了。