I'm attempting to generate some javascript from objective C. I have a simple objective-c object: only NSString
s, NSArray
s, NSDictionary
s, and NSNumber
s - and I'd like to insert it as an object literal into javascript. What's the best way to do this?
So far I've managed to serialize the object and get a JSON string, but JSON isn't exactly equivalent to javascript object literals. I could insert it as a JSON.parse('%@')
call, but that seems inefficient:
(controller.createWindow).apply((controller), JSON.parse('[\"LoggedIn\",3,1,[0,0,480,320],false,false]'))