probablycorey / wax

obj-c <=> lua bridge for iPhone!

This URL has Read+Write access

wax /
name age message
file .gitignore Wed Aug 26 16:10:06 -0700 2009 added a garbage collection example... was using... [probablycorey]
file FAQ Tue Nov 10 08:49:37 -0800 2009 pre-fix [probablycorey]
file LICENSE Thu Oct 01 09:14:40 -0700 2009 updated readme, added license [probablycorey]
file README.md Thu Oct 15 12:52:21 -0700 2009 updated readme [probablycorey]
directory examples/ Tue Nov 10 08:49:37 -0800 2009 pre-fix [probablycorey]
directory lib/ Sat Dec 12 11:18:17 -0800 2009 http fixes [probablycorey]
file rakefile Sat Dec 12 11:18:17 -0800 2009 http fixes [probablycorey]
directory xcode-template/ Sat Dec 12 11:39:45 -0800 2009 added rake task to update wax lib from within a... [probablycorey]
README.md

Setup

  1. Download wax http://github.com/probablycorey/wax

  2. From the inside the wax folder type rake install. This will install an xcode project template.

  3. Open up xcode and create a new Wax project, it should be located under the User Tempates section.

  4. Build and Run! You've got lua running on the iPhone!

  5. Check MobileOrchard.com's Wax tutorial!

Example

Simple UITableViewController Example

waxClass{"BasicTableViewController", "UITableViewController", protocols = {"UITableViewDelegate", "UITableViewDataSource"}}

function init(self)
  self.super:init()
  self.states = {"Michigan", "California", "New York", "Illinois", "Minnesota", "Florida"}
  return self
end

function viewDidLoad(self)
  self:tableView():setDataSource(self)
  self:tableView():setDelegate(self)
end

-- DataSource
-------------
function numberOfSectionsInTableView(self, tableView)
  return 1
end

function tableView_numberOfRowsInSection(self, tableView, section)
  return #self.states
end

function tableView_cellForRowAtIndexPath(self, tableView, indexPath)  
  local identifier = "BasicableViewCell"
  local cell = tableView:dequeueReusableCellWithIdentifier(identifier)
  cell = cell or UI.TableViewCell:initWithStyle_reuseIdentifier(UITableViewCellStyleDefault, identifier)  

  cell:setText(self.states[indexPath:row() + 1]) -- Must +1 because lua arrays are 1 based

  return cell
end

-- Delegate
-----------
function tableView_didSelectRowAtIndexPath(self, tableView, indexPath)
  self:tableView():deselectRowAtIndexPath_animated(indexPath, true)
  -- Do something cool here!
end

Created By

Corey Johnson (probablycorey at gmail dot com)

More