Created
November 12, 2009 22:17
-
-
Save probablycorey/233358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Note: Lua Proxy Userdata is what holds the reference to the obj-c object | |
function dummyCode(array) -- array is an instance of an obj-c NSArray Object | |
local thing = NSObject:alloc():init() -- Assume the Lua Proxy Userdata for 'thing' is | |
-- automatically put into the strong set | |
... -- Misc Lua code. Assume the Lua garbage collector will be run during this code. Since | |
-- 'thing' is not being retained by any other obj-c code (its retain count is 1) it is | |
-- removed from the strong set. | |
array:insertObject(thing) -- Now 'thing' has been retained by obj-c (its retain count is 2), | |
-- but Lua has no way of knowing it should be added back into the | |
-- strong set. | |
thing = nil -- Now the Lua Proxy Userdata will be destroyed on the next garbage collection, | |
-- yet the 'thing' obj-c object is still being used and will need the Lua Proxy | |
-- Userdata | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment