I created a TTModelViewController. in the createModel Method i created a TTURLRequestModel. after Loading content in the TTURLRequestModel i want to call a method in my TTModelViewController.
TTModelViewController
- (void) createModel {
requestModel = [[singlePostModel alloc] initWithId:@"54"];
}
- (void)didLoadModel:(BOOL)firstTime {
NSLog(@"loaded");
}
TTURLRequestModel (singlePostModel)
- (void)requestDidFinishLoad:(TTURLRequest*)request {
//doing something
[super requestDidFinishLoad:request];
}
first i thought “didLoadModel” gets called after requestDidFinishLoad was called, but its before.
So, how can i call a method in my TTModelViewController after request is finished loading?
is there a method that already does that and i only have to overwrite this? or something else?
thanks
// if knowbody knows how to do this with three20, anybody can tell me how to do this in general?
edit
the solution of the first post works fine now, but i still got a warning that the function i call to my object doesnt exist:
@interface TTModelViewController {
}
- (void)modelFinishedLoading;
@end
and now i call that method in my models class
[controller modelFinishedLoading];
at this point xcode throws a warning “no -modelFinishedLoading method found”.
why? i implemented it in the interface and also in the implementation part of TTModelViewController.
does that have to do with this @class at my singlePostModel?
@class singlePostViewController;
@interface singlePostModel : TTURLRequestModel
The way I would do it would be to subclass
TTURLRequestModel, which I suspect you’ve already done based on the name of your class (singlePostModel). In that subclass, add a member variable that you can use to point back to yourTTModelViewController. Something like:Class Definition:
Implementation:
When you initialize it then, you would use:
Unless you have another way to get to your
TTModelViewController, like through the app delegate singleton, in which case, that could work just as well, as long as you don’t mind the coupling.For example, your app delegate has a reference to the main View Controller for the application because it is set up from the main NIB. That is easily accessible using