Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8566117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:34:58+00:00 2026-06-11T17:34:58+00:00

i try a simple Delegate but the method won’t fire. Here is my code:

  • 0

i try a simple Delegate but the method won’t fire. Here is my code:
The view with the protocol and a button which should trigger the delegate:
ViewController.h

#import <UIKit/UIKit.h>
@protocol InitStackDelegate <NSObject>
@required
-(void)initstack:(NSInteger)amount;
@end

@interface ViewController : UIViewController{
    IBOutlet UITextField *amountTextField;
    __unsafe_unretained id<InitStackDelegate> delegate;
}

- (IBAction)init:(id)sender;

@property (nonatomic,assign)id  delegate;

@end

ViewController.m

#import "ViewController.h"


@interface ViewController ()

@end

@implementation ViewController
@synthesize delegate;
- (IBAction)init:(id)sender {
    //send the delegate

    [delegate initstack:[amountTextField.text intValue]];

}

AppDelegate.h

#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate,InitStackDelegate> {
}  

@property (strong, nonatomic) UIWindow *window;
@property (strong,nonatomic) ViewController *myView;
@end

AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window;
@synthesize myView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    //..... push second controller into navigation stack
    myView.delegate = self;
    return YES;
}
...
#pragma mark Delegate Method
-(void)initstack:(NSInteger)amount{
    NSInteger test;
}

@end

When i hit the button i get to (IBAction) init but then the delegate do nothing. I set a breakpoint in AppDelegate.m but it is never reached. Any help?

thx
Mario

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:35:00+00:00Added an answer on June 11, 2026 at 5:35 pm

    In you App Delegate, when you set myView.delegate=self myView doesn’t actually point to anything!
    You need to set myView to point to your ViewController.

    Use this in didFinishLaunchingWithOptions

    myView = (ViewController *)self.window.rootViewController;
    myView.delegate = self;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought I'd try a simple GUI app using the world/universe mutation-free approach, but
Hi I want to try making a simple application for android phones for which
Web-development novice here. I want to try implementing a simple web site that uses
I try to create a simple heroku app which clones a git repository, invokes
I try to make my simple mock to work, but it's too tedious. I
Ok this may be really simple but everything I try just seems to hit
I try to implement User define Delegate.For that i did this code **- DelegateAppDelegate.h**
I have a simple code, which send from server to clients value to count.
I am using a simple try-with-resources statement like the following: try (final CSVWriter w
in simple I try do that in PhpMyAdmin: update wp_postmeta.meta_value = wp_posts.id where wp_posts.post_name=articles.image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.