-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.rb
54 lines (45 loc) · 1009 Bytes
/
Controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Controller
attr_writer :toolsTableView
def awakeFromNib
@tools = []
@toolsTableView.dataSource = self
end
def numberOfRowsInTableView(view)
@tools.size
end
def tableView(view, objectValueForTableColumn:column, row:index)
@index = index
f = @tools[index]
case column.identifier
when 'manufacturer'
f.manufacturer
when 'tool'
f.tool
when 'location'
f.location
end
end
def tableView(view, setObjectValue:object, forTableColumn:column, row:index)
f = @tools[index]
case column.identifier
when 'manufacturer'
f.manufacturer = object
when 'tool'
f.tool = object
when 'location'
f.location = object
end
end
def addTool(sender)
f = Tool.new
f.manufacturer = ''
f.tool = ''
f.location = 'closet'
@tools<< f
@toolsTableView.reloadData
end
def deleteTool(sender)
@tools.delete(@tools[@index]) if @index
@toolsTableView.reloadData
end
end