Reputation: 25254
i created a TTViewController that should show some Informations from a external (web) source. i already worked with some TTableViewControllers where i used the TTModel System (i created a TTURLRequestModel and a TTListDataSource for my TTTableViewControllers)
whats the way to do this with a TTViewController? is there also something like a DataSource and Request Model or do i have to assign my ViewController with the TTURLRequestDelegate and run a simple URL Request?
im asking because i dont know whats the "best" and "newest" way to fill my viewcontroller with data from the web. i know how to do this for tableviews but not for views.
thanks in advance
edit: some code
my singlePostViewController:
@interface singlePostViewController : TTModelViewController
singlePostModel *_singlepostmodel;
@end
- (void) createModel {
_singlepostmodel = [[singlePostModel alloc] init];
}
and my singlePostModel
@interface singlePostModel : TTURLRequestModel {
}
@end
but what to do now? where to load my stuff and setting it up?
Upvotes: 0
Views: 1487
Reputation: 873
Check this twitter example https://github.com/facebook/three20/tree/master/samples/TTTwitter Its straightforward example.
You need to override "-(void) load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more" method in your subclass of TTURLRequestModel to fetch remote data.
Upvotes: 0
Reputation: 709
Check out the TTModelViewController class. You'll want to subclass that. You create the TTURLRequestModel in the createModel: method and add "self" to the list of model's delegates. There are a bunch of interesting methods available that should be sufficient for what you're trying to do.
In particular, this PDF shows a good relationship between the model, datasource, and controller classes.
Upvotes: 3