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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:33:25+00:00 2026-05-24T10:33:25+00:00

I’m trying to set up protocols and delegation. I have a problem tho that

  • 0

I’m trying to set up protocols and delegation.

I have a problem tho that i wish to set a delegate to a previously allocated object.

The object i am allocating needs to delegate to a protocol. how is this done?

Heres my code.

//SendSMS.h

@protocol ModalViewDelegate

- (void)didReceiveMessage:(NSString *)message;

@end

@interface SendSMS : UIViewController <UITextViewDelegate, UITextFieldDelegate> {


    MessageOptions *messageOptions;
    LoginPage *loginPage;
    IBOutlet UITextField *phonenumber;
    IBOutlet UITextView *smsBody;
    IBOutlet UIScrollView *scrollview;

}

-(IBAction)LoadMessageOptions;

@end

The problem is when the object is pushed onto the stack. Its delegate isn’t that of its self. but that of the object before it.

Any ideas?

UPDATE!

Ok i have managed to set my delegate to [self.navigationController.viewControllers objectAtIndex:0] which is the rootviewcontroller. But i have 3 complier warnings stating that the methods are not found in the protocols. Which they are…. But it compiles runs and works.

  • 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-24T10:33:26+00:00Added an answer on May 24, 2026 at 10:33 am

    Never let an instance set the delegate unto itself. The whole idea with delegates is that you should not need to know who the delegate is. As I understand your architecture it is three levels deep;

    1. View1 is the root controller, it creates and pushes;
    2. View2 that do some stuff and then creates and pushes;
    3. View3 that wants to send some results to whoever is concerned.

    I see two possible solutions.

    Solution 1 – Delegates

    1. Let View3 declare a delegate protocol View3Delegate.
    2. Let View1 conform to View3Delegate.
    3. When View1 creates and pushes View2 also pass it self to hold on to.
    4. When View2 creates and pushes View3 also set the delegate that was passed in step 3.
    5. When View3 wants to send it’s result, call the delegate and be happy.

    Solution 2 – Notifications

    This is probably a more elegant solution in your case, since the previous solution has an extra step where View2 needs to handle stuff just in order to make View1 and View3 work, not related to it’s real responsibilities.

    1. Let View3 declare a notification named View3ResponseNotification.
    2. Let View1 observe notifications of the name View3ResponseNotification.
    3. View1 creates and pushes View2 with no worries.
    4. View2 creates and pushes View3 with no worries.
    5. When View3 wants to send it’s results it posts the View3ResponseNotification notification.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.