Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't call controller method from delegate
    primarykey
    data
    text
    <p>I'm trying to do something like this: <a href="http://www.pushplay.net/2009/05/framework-for-having-multiple-views-in-an-iphone-app/" rel="nofollow">http://www.pushplay.net/2009/05/framework-for-having-multiple-views-in-an-iphone-app/</a></p> <p>So far I've got this structure: appDelegate -> rootViewController -> welcomeViewController</p> <p>I've a method (doSomething) in my delegate, which is called by an IBAction in welcomeViewController. It works, I can do an NSlog in doSomething and it shows the method is being called within the delegate.</p> <p>The problem is when I run a command like [rootViewController loadNewView] in my doSomething method (in the delegate), it does nothing. It doesn't error, it just does nothing.</p> <p>I've been reading and seen protocols and notifications are suggested, but I'd like to know why this method using the delegate doesn't work and if there is any way to fix it.</p> <p>SurveyClientAppDelegate.h</p> <pre><code>@interface SurveyClientAppDelegate : NSObject &lt;UIApplicationDelegate&gt; { UIWindow *window; RootViewController *rootViewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet RootViewController *rootViewController; -(void)doSomething; @end </code></pre> <p>SurveyClientAppDelegate.m</p> <pre><code>- (void)doSomething { NSLog(@"Attempt: rootViewController loadLocationList"); [rootViewController loadLocationList]; } </code></pre> <p>RootViewController.h</p> <pre><code>@interface RootViewController : UIViewController { WelcomeViewController *welcomeView; } @property (nonatomic, retain) WelcomeViewController *welcomeView; @property (nonatomic, retain) SurveyListViewController *surveyList; -(void)loadLocationList; </code></pre> <p>RootViewController.m</p> <pre><code>- (void)loadLocationList { NSLog(@"RootViewController: loadLocationList"); } </code></pre> <p>WelcomeViewController.h</p> <pre><code>@interface WelcomeViewController : UIViewController -(IBAction)viewList:(id)sender; -(void)loadLocationList; </code></pre> <p>WelcomeViewController.m</p> <pre><code>- (void)viewList:(id)sender { SurveyClientAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; [appDelegate doSomething]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload