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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-21-2008, 05:11 PM   #20 (permalink)
Abel
Registered Member
 
Join Date: Jul 2008
Posts: 189
Default

Actually the view controllers are allowed access to w.e the heck they want, when using MVC we simply care about having reusable models and views. Heck if you make a reusable controller then many props to you but thats barely ever possible unless you are working on doing something very generic. The view however shouldn't have direct access to the delegate, any info it needs to display or deal with should be passed to it by its view controller.

Quote:
Originally Posted by cDima View Post
I watched the video, implemented it, I get what you are doing. I'd give you a medal for doing it too.

I may have exaggerated a bit, but let me explain why I don't like that line. The view or view controller in MVC shoudn't know about the TwoViewAppAppDelegate, right?
Because it will never be reusable.

Lets take the UITextView, for example. To send messages UP the view hierarchy, as I understand it, the UITextView defines a prototype called UITextViewDelegate, and a public property called delegate. I believe this is the proper way to create view controllers that send signals to their parents. Right?

So the MVC way of doing that code is:
- define a prototype for the specific ViewController;
- after creating the ViewController in the app delegate, hook the TwoViewAppViewController.delegate to "self" (the app delegate);
- and in the app delegate, implement the prototype;

then from the ViewController you can do this code:

Code:
- (void) someMethod {
    if ([delegate respondsToSelector: @selector(flipToBack)]) {
          [delegate flipToBack]; // do something appropriate
    }
}
...or not? =)
I'm new in all of this, and come from a C# background. Maybe I'm implementing event-based development to make it more familiar.
Abel is offline   Reply With Quote
 

» Advertisements
» Online Users: 353
17 members and 336 guests
ADY, BrianSlick, dacapo, fiftysixty, john love, Joseph Nardone, ligerligerliger, mizzytheboy, nobre84, oztemel, poisenden, Sunny46, syver, themathminister, TheWebWizz, XRumerTest
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,876
Threads: 89,225
Posts: 380,701
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jorge599
Powered by vBadvanced CMPS v3.1.0

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