views:

95

answers:

2

I have an app which displays 10 images and each image is associated with a button and a URL link. I would like to release this app, but be able to update the images and links via the web without needing to do an update to the app.

I know that I can pull images from the web like so:

NSURL *url = [NSURL URLWithString: @"http://example.com/image.png"];
 NSData *data = [NSData dataWithContentsOfURL: url];
 UIImage *image = [UIImage imageWithData: data];
 UIImageView *imageView = [[UIImageView alloc] initWithImage: image];

I assume that it is also possible to pull a plist from the web as well?

What about a .xib and .h/.m files? Could I have my app check a certain URL for new .xib/.h/.m files each time it runs, and when I upload these files to that URL in two weeks time, people who run the app will have it load the new files?

So instead of loading a class/xib from my resources like this:

UIViewController *nextController = [[ClassName alloc] initWithNibName:@"ClassName" bundle:nil];

I would somehow replace the ClassName with new data pulled from the web?

I have seen apps that pull in new data (granted it's usually simple images/text - such as the occasional "news" updates in Doodle Jump) from the web without requiring users to download an update for the app. Any help with the first steps towards making this happen would be greatly appreciated... Thanks!

+1  A: 

You can load resources from the web, but you cannot "compile" anything in a running app, so the .m/.mh/.xib aren't useable.

You can certainly load a plist (or other data file) and use that to reference different images and links. (The http://example.com/image.png above could be dynamic in this sense.)

NWCoder
+2  A: 

Store all of your starting material that's bundled in your app inside the resource folder. On first load, programatically copy all of that material to the bundle Library path. Your app should then only deal with the data inside the library directory. When your app first connects to the web, you can save any new data to the user's library path and overwrite the old stuff.

It's impossible to write to the app bundle directory after it's been compiled, because that breaks Apple's signature.

This is just a high level suggestion, obviously. Without knowing exactly what you want to do it's hard to give a detailed answer. But yes, downloading and storing data is permitted, just not inside the app bundle. You cannot send it new .h/.m files or xibs, unfortunately.

JustinXXVII