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 07-23-2010, 03:44 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 17
Appwizz is on a distinguished road
Default calling action from another viewController?? HELP!

Hey guys, I am having trouble calling an action from another viewController so basically here is what it is in a simpler form. I have two viewControllers, (MainViewController, and OptionsViewController ) and i have a button in the OptionsViewController and when i press that button, I want it to do something in the MainViewController...... any help is appreciated... By the way, I have already tried putting "[MainViewController performSelector:@selector(changeNow)];" and It builds fine but the action does not work, again any help is greatly appreciated! THANKS!
Appwizz is offline   Reply With Quote
Old 07-24-2010, 10:40 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Quote:
Originally Posted by Appwizz View Post
Hey guys, I am having trouble calling an action from another viewController so basically here is what it is in a simpler form. I have two viewControllers, (MainViewController, and OptionsViewController ) and i have a button in the OptionsViewController and when i press that button, I want it to do something in the MainViewController...... any help is appreciated... By the way, I have already tried putting "[MainViewController performSelector:@selector(changeNow)];" and It builds fine but the action does not work, again any help is greatly appreciated! THANKS!
A few approaches.

One have a reference to it in your app delegate, create a method in your app delegate that the options view can call, then in that method call your main view method.

Two, have your options controller hold a reference to the main controller, then call the method directly.

Three, maybe the method in main view controller doesn't belong there. Think OO and who should be responsible. Sometimes we think a particular class should be responsible, and we definitely have been giving view controllers a lot of responsibilities that adding just one more is easy to do.

This is one thing about objective-c and iOS development is that they sometimes don't follow best OO practices for the sake of ease. Not that this is wrong.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Reply

Bookmarks

Tags
action, calling action, viewcontroller

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: 343
14 members and 329 guests
alexP, appservice, bignoggins, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, mariano_donati, Objective Zero, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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