Saturday, January 1, 2011

JANews.h - Class to download plain-text news

Here's a simple class that can help a developer keep in touch with users. By posting a specially formatted plain-text file online and point this class to the URL, your app can download a custom news message to display in your app along with a URL to direct the user to.

The formatting of your text file is as follows:
A simple news announcement goes here, in front of two hash marks, and a link goes after the hash marks, like so##http://www.google.com
Save something like that in a plain-text, non-rich .txt file with no HTML markup, and post it online with a public link. I suggest Dropbox.

To configure the class, change line 17 in JANews.h to point to the URL of your text file.
#define JANewsURL @"YOUR_PLAIN_TEXT_HTTP_URL_HERE"
Be sure to register any interested class with the NSNotificationCenter with the name @"JANewsDidReceiveNews". You will need to use your registered selector to check that the incoming object is not NSError, because the class sends an error object if the connection fails.


There are methods to serialize downloaded news to device flash memory.  Refer to the .h and .m files for more documentation.


The class can be downloaded from MediaFire!

No comments:

Post a Comment