“eval” for Objective-C code

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 21:21:20

问题


Does a method like eval exist in Objective-C as in Javascript, Ruby, PHP, or Python?

I use PhoneGap and I want to create a window which is specific for each of my projects, and I can't use an HTML file. So I want to call a method from JavaScript and, with one of the arguments being Objective-C code to be interpreted.


回答1:


Sorry, there is no "eval" method in Objective-C, and the iPhone license specifically prohibits interpreted code. You can specify a xib/nib file by name, however.




回答2:


Try this

NSString *returnOfJavascriptExecution = [webView stringByEvaluatingJavaScriptFromString:@"[your javascript code]"];


来源:https://stackoverflow.com/questions/2550897/eval-for-objective-c-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!