开发者

Accessing Objective-C Instance in Wax

开发者 https://www.devze.com 2023-03-13 14:01 出处:网络
There are some use cases I want to create instance of certain objects in objc and access them in Lua/Wax.

There are some use cases I want to create instance of certain objects in objc and access them in Lua/Wax. I read the entire documentation but I'm still uncertain how to accomplish this.

Some Demo Code (doesn't work, but you should get the idea)

galaxy = UIApplication:sharedApplication():delegate():galaxy() 
starclusters = galaxy:starclusters() 
galaxy_drawing = 
UIApplication:sharedApplication():delegate():galaxyDrawing() 
function set_starcluster_position_in_galaxy (x) 
starclusters:objectAtIndex(0):setValue_forKey("position_in_galaxy_x", 
300) 
    puts("Setting Starcluster Position X") 
end 
开发者_StackOverflow

Disclaimer: I'm seeding some Google Groups iPhone Wax Questions on Stackoverflow


Wax Developer Corey wrote

If galaxy:starclusters() returns an NSArray, wax will automatically change this to a Lua array. This might be the problem

If you want to directly change the value of an NSArray or NSDictionary from Lua, and have the changes reflected in Objective-C that won't work right now, because Lua doesn't get the actual reference to the NSArray or NSDictionary back. Corey

Source: http://groups.google.com/group/iphonewax/browse_thread/thread/3042002cddfadc9c

0

精彩评论

暂无评论...
验证码 换一张
取 消