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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-10-2010, 10:14 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 26
jhockman is on a distinguished road
Default Probably a very basic solution

I have 3 UIViewControllers. Both need to have access to the same information and be able to run the same Method.

So my main view controller handles all the info and passes it as an argument to either view controller through a common function.

so I don't have to continually check which view is active (because for the purposes of this application it doesn't matter. All I'm doing is displaying the same info two different ways) i have a separate UIViewController object that I do not initialize and instead just assign the active view controller to it.

So I have MVC, VC1, and VC2. VC1 and 2 are initialized and are their own subclass of UIViewController. MVC is of UIViewController but not initialized. When I switch views I assign MVC = VC1 or 2.

The method I need to use is not a UIViewController method so it gives me a warning saying that MVC may not respond to selector. It works fine, but I just want to get rid of the warning. How can I go about doing this if both VC1 and VC2 are their own separate subclasses of UIViewController.

The only thing I can think of is to create another subclass of UIViewController that has the method I need to use. Make both VC1 and VC2 a sublclass of that and then make MVC that class. But I'm just trying to see what other options are out there so I might learn something more.

Also if the way I am handling the separate views is way off key, dangerous, or just bad practice please help me out and suggest something better.

Thanks!
jhockman is offline   Reply With Quote
Old 09-11-2010, 03:37 AM   #2 (permalink)
N3RD
 
Join Date: Oct 2009
Posts: 201
tychop is on a distinguished road
Default

Why not just subclass 2 UIViews & add them to the VC (self.view = ) when needed?

Quote:
"The method I need to use is not a UIViewController method so it gives me a warning saying that MVC may not respond to selector."
You need to add the method signature to the header.
tychop is offline   Reply With Quote
Old 09-11-2010, 07:02 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 26
jhockman is on a distinguished road
Default

That's actually something I will keep in mind for the future, but for the purposes of this app I don't think that would be the most efficient way. Both views are displaying the same info but one is a map and the other is a list so they both need a completely separate set of methods to get their data to display properly. I could still do it that way, but from my understanding and how I've done it so far the VC would taking on so many protocols that it would (for me anyway) be far too cluttered to really keep track of. Correct me if I misread what you were saying. Or if you have any advice.

Thanks for the suggestion
jhockman is offline   Reply With Quote
Old 09-12-2010, 10:19 AM   #4 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 107
JDave is on a distinguished road
Default

Create a delegate that all 3 UIViewControlllers 'talk' to ... or manually send the data back and forth using usual class communication methods. I use a delagate when I have 3 or more viewControllers, just to simplify the code...
JDave is offline   Reply With Quote
Old 09-12-2010, 02:31 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 26
jhockman is on a distinguished road
Default

Quote:
Originally Posted by JDave View Post
Create a delegate that all 3 UIViewControlllers 'talk' to ... or manually send the data back and forth using usual class communication methods. I use a delagate when I have 3 or more viewControllers, just to simplify the code...
Ah okay. I will try that out. Thanks!
jhockman is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 347
13 members and 334 guests
bignoggins, carlandrews, cgokey, flamingliquid, givensur, hzwegjxg, ilmman, jenniead38, linkmx, mraalex, PixelInteractive, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:55 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0