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, 12:09 PM   #14 (permalink)
exorcyze
Registered Member
 
Join Date: Dec 2008
Posts: 495
exorcyze is on a distinguished road
Default

Well I'm not going to say this is the best approach, but I can tell you some of the things I typically do.

1. Controlled views have a controller property. You could either do this generically or specifically ( IE UIViewController *controller or RootViewController *controller ). There is a pro/con to both approaches. The first is more generic and will fill most circumstances for passing interaction delegation back to the controller (IE, setTarget, performSelector, etc ). If you need to access specific method calls on the controller however it will require a tiny bit more typing if you want to be proper about it and cast it.

2. UIViews that are controlled ( IE base views ) don't handle any interaction themselves - anytime something happens it isn't even seen by the view. For example if I have a MenuView that creates some buttons, then when I set them up their target for the event is self.controller. It keeps things cleaner IMO, and means I have less work to do if I refactor because I didn't like the method name I chose - because then I don't also have a sub method in the view.

3. Controls / Widgets typically don't have an associated controller. For example if you're making custom table cell or button implementation, or a game sprite actor. They're just for display and they should be able to be controlled by anything that wants to use them.

4. For advanced controls that have very specific interactions and callbacks that need to happen I like to use delegates. It's how Apple has done things, it works well and it's pretty simple after you've done it a couple times. Plus it's nice to be able to see in the header what protocols are being implemented - as Colionel pointed out very correctly, it shouldn't matter *what* is using your control, just that it conforms to the expected interfaces.

Just some thoughts off the top of my head. =)
__________________
My Apps on AppStore : gScale (guitar scales reference), eMaze, eMaze Lite, eTimesheet
exorcyze is offline   Reply With Quote
 

» Advertisements
» Online Users: 537
19 members and 518 guests
Apptronics RBC, Bryan1, chiataytuday, DaveDee, dljeffery, ilmman, jmorregoc, mariano_donati, mediaspree, mox, mpsventas, Newbie123, newprogrammer, oceanlablight, Simba, skrew88, Speed, zin
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,316
Threads: 93,990
Posts: 402,428
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:08 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.