Saturday 15 February 2014

cocoa touch - Is it OK to use notification center to reload a UITableView? -


I was asked not to abuse the notification center and because I am trying to learn the proper IOS dev. I came to know that there are many ways to work, but this does not mean that it is correct or the most efficient.

Here's an example: I wrote an RSS feed reader app, in a nutshell I also downloaded thumbnails to load all data from the Singleton class web, and my image for each table was cached (Table view cell post title, thumbnail and date).

Users have the option of refreshing data at any given time, which basically sets all my data and thumbnail arrays to zero, then refreshes new data. (I know that all my data is disappearing, so the core data would be a better option for this).

So here's the question - I use the notification center (the default center) from my singleton class again to load and stop Spinner in my table controller when the data is loaded and ready for use it happens. It works like a charm, but is it fair IOS programming, in other words, this is something I can show to people (job interview etc.)? (If not, how will you do it?)

I do not see anything wrong in using notification But personally I think that the notification is more suitable for those situations which need to communicate with two unrelated objects in another way (or related objects), but the relationship is through many nodes, which is one -Computer code in the context of others At will). For your problem, table view can be used directly by RSS Singleton, e.g.

  - Tap refresh {{[[RSSFeed Singleton] LoadData WithSocialSlow Block: ^ {// Reload Table // Make sure you work on the main thread using GUI Dispatches_assink Use} Failure: lock: ^ {// handle error}}   

Where RSSFeed is the singleton class that controls the loading data, maybe it's good ?

Another use of the notification is for "global" incidents, as if iOS is often used (such as the app to enter the background / foreground) so that no one knows them. An example: If you want, refresh the feed from time to time (without user pressing the button), the information will be a good option (possibly only the only choice).

I have not seen my app and ever display problem remove obscure ... is the only hold to add, when your view is dealloc'ed.

No comments:

Post a Comment