Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created April 9, 2012 13:21
Show Gist options
  • Save fjolnir/2343350 to your computer and use it in GitHub Desktop.
Save fjolnir/2343350 to your computer and use it in GitHub Desktop.
objc.class_setMetaTable({objc.NSDictionary, objc.__NSCFDictionary, objc.NSMutableDictionary, objc.__NSCFMutableDictionary }, {
__tostring = objc.objToStr,
__index = function(self, key)
local val = objc.getInstanceMethodCaller(self, "objectForKey_")(self, Obj(key))
if val ~= nil then
return val
end
return objc.getInstanceMethodCaller(self, key)
end,
__newindex = function(self, key, val)
return objc.getInstanceMethodCaller(self, "setObject_forKey_")(self, Obj(val), Obj(key))
end
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment