Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

qwertywelch

macrumors newbie
Original poster
Oct 16, 2010
7
0
Hello!

I am retreiving a text file from my web server and loading its contents into an NSString called "latestCode". NSLog tells me that it is getting the right code, but now how do I execute it?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
While objective-c does allow you to dynamically load frameworks, it does not allow for dynamic execution of arbitrary code. It is not an interpreted language, code must be compiled into a binary object.

-Lee
 

qwertywelch

macrumors newbie
Original poster
Oct 16, 2010
7
0
While objective-c does allow you to dynamically load frameworks, it does not allow for dynamic execution of arbitrary code. It is not an interpreted language, code must be compiled into a binary object.

how would I go about compiling one block of code that can be loaded from a web server & executed?
 

dantherevelator

macrumors regular
Oct 8, 2007
148
0
Well, it's not straightforward, and probably impossible on iOS. Objective C must be compiled to run, and I assume this is raw source code, yes?

If it's an OS X app, and you're feeling adventurous, you might look into something like f-script.
 

qwertywelch

macrumors newbie
Original poster
Oct 16, 2010
7
0
Well, it's not straightforward, and probably impossible on iOS. Objective C must be compiled to run, and I assume this is raw source code, yes?

If it's an OS X app, and you're feeling adventurous, you might look into something like f-script.

It's an OS X app. F-script looks like just what I need, thanks!
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I can point you to objc_loadModules that you can search for... I suppose you could use system or NSTask to invoke gcc, then load the object file with the function mentioned above. This seems quite involved though. Perhaps you could give some background and another method such as distributing a bundle, loading with NSBundle, then executing the new code (though this is still involved) could be suggested? Assuming your end users have a compiler and libraries installed is ill-advised.

-Lee

EDIT: Hadn't really looked at f-script. Looks fancy, and if that will do the job for you it's probably better than the options I mentioned.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.