Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-22-2009, 06:03 AM   #9 (permalink)
colionel
Registered Member
 
Join Date: Jul 2009
Posts: 30
colionel is on a distinguished road
Default

I have a different point of vue, i dont think that using :

Code:
if ([myDelegate isKindOfClass:[UIViewController class]]){
  //take appropriate steps
} else if ([myDelegate isKindOfClass:[WeirdCustomObject class]]){
  //take appropriate steps
}
is the appropriate method... Delegation is made to avoid that. (What if you rename, add or remove a controller ? you will have to edit your view, which is the opposite of the separation of concern principle : your component should not need to know which controller implement it.
Imagine that the UITableView component was supposed to check which controller is calling it to know what to do : each time you create a new app you would have to edit the UITableView code, it would be absurd)

You have to declare a protocol in your view; any controller which needs to receive messages from your view will set itself as delegate of your view,
and when when you need to display a modal view, call your delegate.


In your view you have :

Code:
if(somethingHappened) {
  [delegate presentModalView];
}
Then in each different controller you will have :

in the set up :
Code:
theView.delegate = self;
and the protocol implementation :

Code:
-(void) presentModalView {
 //present the appropriate modal view according to the controller
}

Your view should never directly present a modal view controller, it's the controller job.
The view is only here to display stuff and send message when user do something.

Vincent.

Last edited by colionel; 10-22-2009 at 06:10 AM.
colionel is offline   Reply With Quote
 

» Advertisements
» Online Users: 536
21 members and 515 guests
alexonit, Apptronics RBC, Brian965, Bryan1, DaveDee, dljeffery, Hassasin, inkcpp, ipodphone, Kryckter, leostc, mox, mpsventas, Newbie123, oceanlablight, Simba, skrew88, Speed, timle8n1, zin
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,316
Threads: 93,989
Posts: 402,430
Top Poster: BrianSlick (7,978)
Welcome to our newest member, Simba
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:03 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.