Skip to content

Instantly share code, notes, and snippets.

@rweichler
Last active May 11, 2017 22:01
Show Gist options
  • Select an option

  • Save rweichler/8ffda5ce6c861e91eb1b024d3c47bbad to your computer and use it in GitHub Desktop.

Select an option

Save rweichler/8ffda5ce6c861e91eb1b024d3c47bbad to your computer and use it in GitHub Desktop.
objc = require 'objc'
local count = 0
local function genclass(super)
super = super or 'NSObject'
count = count + 1
local name = 'GENERATEDCLASS_'..count..super
objc.class(name, super)
return objc[name]
end
function VIEWCONTROLLER(title, callback)
local m = genclass('UIViewController'):alloc():init()
m:setTitle(title or '')
if callback then
function m:viewDidLoad()
callback(m)
end
end
return m
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment