开发者

iOS: Download script and execute it?

We have an app that basically parsers some web pages. The thing is the structure of the web page changes sometimes so we need to issue an开发者_StackOverflow社区 update (wait for apple's approval of course). We would like to have the ability to have some kind of a "script logic" on our server that can be sent to the app whenever needed. JavaScript code is possible, but I don't want to have a UIWebView just for parsing some strings. Is there some kind of alternative?

Thanks


No. Running executables or scripts which are not an embedded component of your application is explicitly forbidden by the developer program license agreement:

3.3.2. An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework.


If you are mainly looking for a way to parse strings, one possibility is using regular expressions to do the job and thus provide the definition for those regex in a text or xml file that you can download. This is not a full scripted solution, like one where you download the code and execute it, but it should work equally well. I suppose this should be also completely ok with Apple terms.

There are several frameworks for iOS that offer regex support: RegExKit, AGRegEx, and in iOS 4 you have also NSRegularExpression.


You could embed a scripting language like lua. See here and here. I don't know too much about it, but it's used in lots of applications for scripting, just like your needs.

I'm not 100% how to integrate it or if scripts can be hot loaded, but it will probably work.

Note:

I'm not sure if Apple would let you download and run arbitrary scripts, but it's worth a shot.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜