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 604845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:04:55+00:00 2026-05-13T17:04:55+00:00

I have a project in which the SwitchViewController is root controller It loads the

  • 0

I have a project in which the SwitchViewController is root controller
It loads the viewcontroller2 in some status,
viewcontroller2 load modalviewcontroller1 in some status.
There is one function ‘okButtonPressed’ in modelviewcontroller1(breakpoint 1),
I hope it can notify viewcontroller2 and call the function ‘dosomething'(//breakpoint 2)

So, I set a protocol, all viewcontroller(switchviewcontroller,viewcontroller2,modalviewcontroller1)
contain the protocol

I set breakpoint1 and breakpoint2 as below.

There is no any error reported, but no stop at breakpoint 2, ‘dosomething’ was not executed.

Welcome any comment

Thanks
interdev

//----------------------------------------------source codes

//myprotocol.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


@class Myprotocol;

@protocol MyprotocolDelegate <NSObject>
 @optional

- (void)function1  ;

 @end
//-----------------------------------

@interface Myprotocol :  NSObject {

    id <MyprotocolDelegate> delegate;
}

@property (nonatomic, assign) id <MyprotocolDelegate> delegate;

@end
//myprotocol.m


#import "myprotocol.h"
@implementation Myprotocol
@synthesize delegate;

- (void)dealloc {     
    [super dealloc];
}
@end

//"ModalViewController1.h"
#import <UIKit/UIKit.h>

#import "myprotocol.h"

@interface ModalViewController1 : UIViewController <MyprotocolDelegate>  {
 id<MyprotocolDelegate> delegate;   
}
 @property (nonatomic, assign) id<MyprotocolDelegate> delegate;

- (IBAction)okButtonPressed:(id)sender;
@end

//"ModalViewController1.m"


#import "ModalViewController1.h"

@implementation ModalViewController1
@synthesize delegate;

- (IBAction)okButtonPressed:(id)sender;
{    
    [delegate function1];//breakpoint 1
    [self.view removeFromSuperview];     
}  

//------ViewController2.h"
#import <UIKit/UIKit.h>

#import "myprotocol.h"


@class  ModalViewController1 ;
@interface  ViewController2 : UIViewController  <MyprotocolDelegate>{
  ModalViewController1 *vModalViewController1;
    id<MyprotocolDelegate> delegate;

}
@property (nonatomic, assign) id<MyprotocolDelegate> delegate;
@property (retain,nonatomic) ModalViewController1 *vModalViewController1;
@end

//----ViewController2.m"--------------
#import "ViewController2.h"
#import "ModalViewController1.h"

@synthesize delegate;

- (void)function1; 
{
    [self dosomething];//breakpoint 2  
}

//SwitchViewController.h

#import <UIKit/UIKit.h>

#import "myprotocol.h"


@class  ViewController2;

@class  ModalViewController1 ;


@interface SwitchViewController : UIViewController <MyprotocolDelegate> {

     ViewController2 *vViewController2;

}    

@property (retain,nonatomic) ViewController2 *vViewController2;

@end

//in SwitchViewController.m

ViewController2 *vvViewController2=[[ViewController2 alloc]
       initWithNibName:@"View2" bundle:nil];
self.vViewController2=vvViewController2;

[vvViewController2 release];
[self.vViewController2 setDelegate:self];
  • 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-05-13T17:04:56+00:00Added an answer on May 13, 2026 at 5:04 pm

    For this to work you need to set your instance of ViewController2 as the delegate for ModalViewController1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project which has some lib's associated with it (in Build Path).
I have a project which builds correctly from the command line. On one of
I have a project which is full of compile time errors? Is there is
I have a project which has a main form and some other forms. When
I have a project which upload multiple files so kindly if any one have
I have a project which has lots of modules, each one has different running
I have a project which has a view controller as initial screen and then
I have a project which has Area called Admin. There is a class called
I have a project which I can exclude some of libraries from linker and
I have a project which will need to have some Java layer. I am

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.