UITableView Add Rows At The Bottom Using Parsing Another Page - iphone

I am working on an example project for learning purposes. I have successfully parsed a wordpress site by parsing RSS feed using NSXMLParser. The custom cell includes thumbnail, title, author and published date of posts.
Currently its showing the first page of feed containing 10 posts. I can access the second page of the feed http://sitename.com/feed/?paged=2 and and third page by putting /?paged=3, if i type them in the browser.
What i want to do is when user scrolls down to the bottom, it uses the second page feed url and show the posts at the bottom and so on. Can anyone guide me how to accomplish this task.

Coneybeare has the right idea on how to set it up.
Use AFNetworking, it'll make your life way easier.
I would have an int counter that keeps track of which URL has been last called. Then, as soon as the user gets to the bottom most cell (which you know via a delegate method), I would increase the int by 1, and then append that to the String that represents the URL. You can use the stringByAppendingString method for that.
Now you have a new String with the correct url, and you can fire off a new request, and append the data to what you already have. Then you can do [self.tableView reloadData] to refresh the table.

To make an infinite scroller, you need to know when to start fetching the new items. There are many ways to do this, but the best place is to hook into the UITableViewDelegate's methods. When cellForRowAtIndexPath: is called, check if the row is the last in your data store. If it is, make the call for the new data, then append it to the old data and refresh your view. You can also hook into the table views scroller to see when it it X percent scrolled to the bottom to make this call.

Related

GWT Place objects

I'm new to GWT so this may be a dumb question but I didn't find a good answer to it anywhere.
So, how should I create Place objects in GWT? Should I create them as finals in my ClientFactory and reuse them everywhere?
the Place objects Eclipse generates eat a string token as their parameter what should it be?
My Understanding is the following: I should create final Place objects in my ValueChangeHandler for those pages that are static and reuse them everywhere. Those 'Place's that are relatively dynamic should be created like
new MyCoolPlace("MyCoolPlace" + someRandomNumber)
but isn't it kind of dumb using random numbers each time i need to navigate to a new page? also will the history be cleared of the objects which i created say hours ago?
Currently I have a problem with figuring out how this mechanism works:
I have a form. For, say, adding vegetables to the DB
1. User fills it
2. Submits it
3. Gets to a thank you page
4. Clicks a link in the menu to add a new vegetable
5. Gets to the form but it's already pre-filled with the values user previously entered.
I need the form clean on step 5. But if the user clicks the browser's back button on step 3 I want it to be pre-filled.
Question about final:
I think not. They are lightweight objects and places can have values into them. They are not a limited set of places values (at least if you parametrize them).
Question about form values:
The normal behaviour is when yo go back to -let's say- "vegForm" you obtain the clean view (it's because your URL token is simple vegForm). What happens I think it's you're reusing your view without initializing. Your presenter (or whatever has the UI logic) should obtain the view and call "reset()" "init()" or whatever you want.
If you want to hold your values when you go back you should save them in your place object. It is: field values. And your PlaceTokenizer (the object that transform between URL and Place object) should take care of them. By example: vegForm/potato,green,... (don't remember the standard notation).
The problem is how do you save into the URL the values you entered before clicking Save?
What I'd do is "saving" that state into the URL before saving:
History.newItem("vegForm/potato,green,...", false);
And that will get into the history stack. When I say false it means that the GWT History mechanism should not react to that URL avoiding loading the view again. When your user clicks back she should go back to form(with values). If your user clicks back again the she should go back to form(clean).
By example:
User clicks add veg -> #vegForm
User fills data and pless save
-> #vegForm/value1,value2 (saved in History with false argument)
-> #okPage
User clicks back
-> #vegForm/value1,value2 (form with saved data)
User clicks back
-> #vegForm (form without)
Initialization
Take into account you always must initialize the view.
If you don't have params, to clean it (it can be a reused view)
If you have params, to fill the form with them

if rss feed has only one item how to go straight to its detail view without using a table

I have an rss feed with only one item in it.I am trying to go straight to showing its details without having to go through a table view to do it.
I have a different rss feed working in my app that has multiple items. I have this working with a table view.I was looking online and all I could find was how to display a feed through a table view.
Does anyone know how to display the singular item from the feed in an app?
or of any online tutorials?
Any and all help much appreciated.
Just parse the feed and insted of showing in tableview ,show it in a label or textview .
I don't understand what u trying to ask through your question. It sounds simple but can you elaborate or give url of Rss feed links for understaning ur query...
If you've parsed your data already, you have it stored in a set of variables, right?
So now you just want a particular data to display in detail view for this if you use (UIWebView for DetailView) used this or a particular you wish to publish in the details view:-
– loadHTMLString:baseURL:
Sets the main page content and base URL.
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
Parameters
string
The content for the main page.
baseURL
The base URL for the content.
k...

What is the three20 method of passing objects between view controllers?

I have a basic RSS Reader I made from three20 tutorials using TTLauncherView as a menu to different feeds and TTTableViewController to show the feed list.
However, I am stuck at the point where from the feed list I click to view the feed item details. I use TTTableImageItem to display my feed items and I'm clueless as to how I am to use the URL variable in said TTTableImageItem to pass objects to the view controller showing the feed item.
I did some searching and I am lead to think that this cannot be done except via TTURLRequest, which leaves me even more confused.
Most of my code is adapted from IOSGuys tutorial, which uses a custom data source, data model and parser. I have tried making the data source and data model a singleton but to no avail and I'm unsure if that's even the best way to proceed for something as (presumably) simple as this.
Ideally I intend to pass the entire array of feed items with another argument for the index so that I can make use of UIPageControl to swipe between feeds when I'm at a more in-depth view.
Much help is appreciated! I have been spending too long looming around already!
The usual way of doing this is to have some sort of global singleton Data Manager class that manages the data models through Core Data, In-Memory Stores or other ways. Each model would have some sort of unique identifier. Doing it this way lends itself to a URL only stack needed to recover your navigation history without having to write state out to file in order to restore. You also can bring up any page in the app at any place with only a single URL. Using a URL scheme only then becomes trivial as you can do something like:
yourapp://blogs/jd82kd9
and have the blog view controller's init method contact the Data Manager for the blog with the unique identifier of jd82kd9
In your navigator's mappings, you would have something like this:
[map from:#"yourapp://blogs/(initWithBlogID:)") toViewController:[MyBlogViewController class]];
and then the initWithBlogID method would have the signature:
- (id)initWithBlogID:(NSString *)blogID;
see also Three20 : how to pass a class of objects between 2 views

How to display Data from RSS Feed in Parts in Iphone Application

I am displaying RSS feeds in my table view.
as there are hundred of feeds so my application takes lots of time to load them and display them i want to load just first 25 feed and display them in Table view and when User Click on More 25 application load next 25 and display them.
Any Idea........... :)
I am using TouchXML to parse XML Feed.
It depends on the webservice that provides you the RSS feed. If you can request them to load just 25 feeds, then the server side is ok
Now is the client side, you need a UITableView as usual. In the numberOfRows delegate method, you return 25 (also need to +1 for last cell), and shows the first 25 feeds. At the bottom of the table view the last cell can be a cell with text "Load More", then here, you started to load more
You can also put the loading and parsing RSS feed in thread, this will boost your performance
While parsing if you encounter a feed store it in a arry... if the array count is 25 display display it in table view continue parsing if the user click on more button display next 25 elements in the array to the tableview.
as vodkhang told Use thread if you want to boost performance.
Take a look at the SeixmicXML example and the LazyTableImages sample code on the apple developer web site. They use threading (NSOperation) for parsing batches of data and load them on a table view.

How to limit parsing and display the previously parsed contents in iPhone?

I am new to iPhone development. I am parsing a URL and displayed its content in the table. On clicking a row it plays a video. When I click a done button, I once again call the tableview.
When I call the table view it parses the URL once again to display the contents. I want to limit the parsing for 1 time and for the next time I want to display the contents which are parsed at the first time. How can I achieve it?
Not to sound condescending, but, don't do that? When the results are first requested, parse them and store the parsed results. From there on out, only return those.
Without more information about your problem, it seems that trivial.