Class: Nitron::TableViewController::ArrayDataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/nitron/table_view_controller.rb

Instance Method Summary collapse

Instance Method Details

#initWithCollection(collection, className: className) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/nitron/table_view_controller.rb', line 75

def initWithCollection(collection, className:className)
  if init
    @collection = collection
    @className = className
  end

  self
end

#numberOfSectionsInTableView(tableView) ⇒ Object



84
85
86
# File 'lib/nitron/table_view_controller.rb', line 84

def numberOfSectionsInTableView(tableView)
  1
end

#objectAtIndexPath(indexPath) ⇒ Object



88
89
90
# File 'lib/nitron/table_view_controller.rb', line 88

def objectAtIndexPath(indexPath)
  @collection[indexPath.row]
end

#sectionForSectionIndexTitle(title, atIndex: index) ⇒ Object



92
93
94
# File 'lib/nitron/table_view_controller.rb', line 92

def sectionForSectionIndexTitle(title, atIndex:index)
  nil
end

#tableView(tableView, numberOfRowsInSection: section) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/nitron/table_view_controller.rb', line 96

def tableView(tableView, cellForRowAtIndexPath:indexPath)
  @cellReuseIdentifier ||= "#{@className.gsub("ViewController", "")}Cell"
  unless cell = tableView.dequeueReusableCellWithIdentifier(@cellReuseIdentifier)
    puts "Unable to find a cell named #{@cellReuseIdentifier}. Have you set the reuse identifier of the UITableViewCell?"
    return
  end

  cell
end