I am a java developer learning Objective C for an IPhone project, my question is about the OOP design in Cocoa. I have a view based application which communicates with a web service and recives an xml, parse it and map its contens an appropriate view component (e.g if thats a date show the question with datepicker, if question has 2 values show it with a segmented control, if more with a pickerview..etc) so its a dynamic questionary with many pages.
What is the best design possible here considering the cocoa framework, for instance if I create a class called "Connection" for making web request, can I create a connnection object from my ViewController class and use it? or I should use delegete classes for that..because my class will include methods like:
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
Does this kind of implemented methods above must have placed in a viewcontroller class?
And second question, how can I do the design for the mapping the xml response into related UI view components? I want to make the code as object orient as possible and not too many if elses in my view controller class, but instead it should only receive a let's say "uiview object" filled with necessary view components and it will just show it. but the mapping and reasoning should be done somewhere else..where can I do that and then where can I put the methods like for instance;
-(NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return [itemArray count];
}
does this have to be in a controller class? if not how can I access this methods.
Hope I could made my self clear.