Restkit + iOS (#1)

I commenced on making an iPad at the start of the semester and by and large towards the end I have learnt so many concepts. I am going to detail out solutions, some common ones, found out from the web or forums or just pure ingenuity.
I am not a big iOS coder, I am more familiar with javascript, java, python and C. But then again its the same MVC principle all over again. Although, the standard way of doing some things in XCode would be to use protocols, I don’t usually find myself very familiar with these constructs. So here are my solutions/tips.
Troll No 1:

You have 2 view controllers, master and detail, you want to load something (a GET request) to your detail panel (which is a hierarchy of navigation controllers). You can do it via a GET request in the root view controller of the navigation controller in the detail panel but you want to do it via the master view controller since it is at a higher level.
here’s how I did it.
NavigationController has a property called viewControllers which stores the stack of view controllers. The first one is the controller you wish to invoke as delegate. All you need to do is this:

UINavigationController* v1 = [self.splitViewController.viewControllers objectAtIndex:1];
[[RKClient sharedClient] get:@"/hello" delegate:[v1.viewControllers objectAtIndex:0]];

All you need to is make a get request via the RKClient and pass the delegate to be the first view controller in the navigation stack.
Its not clean, but does the job :-)


Post a Comment