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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:53:18+00:00 2026-05-14T08:53:18+00:00

I am new to iPhone and objective c. I have spent hours and hours

  • 0

I am new to iPhone and objective c. I have spent hours and hours and hours reading documents and trying to understand how things work. I have RTFM or at least am in the process.

My main problem is that I want to understand how to specify where an event gets passed to and the only way I have been able to do it is by specifying delegates but I am certain there is an easier/quicker way in IB.

So, an example.
Lets say I have 20 different views and view controllers and one MyAppDelegate.
I want to be able to build all of these different Xib files in IB and add however many buttons and text fields and whatever and then specify that they all produce some event in the MyAppDelegate object. To do this I added a MyAppDelegate object in each view controller in IB’s list view. Then I created an IBAction method in MyAppDelegate in XCode and went back to IB and linked all of the events to the MyAppDelegate object in each Xib file.

However when I tried running it it just crashed with a bad read exception.

My guess is that each Xib file is putting a MyAppDelegate object pointer that has nothing to do with the eventual MyAppDelegate adress that will actually be created at runtime.

So my question is…how can I do this?!!!

  • 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-14T08:53:18+00:00Added an answer on May 14, 2026 at 8:53 am

    If you create an instance of MyAppDelegate in each nib file then, yes, you do end up with a lot of different instances of the class when all the nibs load. The app delegate is not identified by class or even protocol but rather by being the object pointed to by the application instance’s delegate property. To find the true app delegate, you have have to ask the application object itself for its delegate

    You should have all your view controllers descend from a parent view controller class that has an appDelegate property. Implement something like this:

    #import "MyAppDelegateClass.h"
    
    @interface ViewControllerBaseClass :UIViewController {
        MyAppDelegateClass *appDelegate;
    }
    @property(nonatomic, retain)  *appDelegate;
    
    @end
    
    @implementation ViewControllerBaseClass
    @synthesize appDelegate;
    
    -(MyAppDelegateClass *) appDelegate{
        self.appDelegate=(MyAppDelegateClass *)[[UIApplication sharedInstance] delegate];
        return appDelegate;
    }
    @end
    

    When the view controller needs the app delegate it just calls self.appDelegate. If you want to access an attribute of the app delegate use self.appDelegate.attributeName.

    The important thing is that you ask the application for its specific delegate instance at runtime. You can’t do that from a nib file.

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

Sidebar

Related Questions

I am relatively new to Objective-C / iPhone programming, and have only created single
I am new to the whole iPhone SDK and objective C, but have managed
I am new to Objective-C and iPhone I have to sort a NSDictionary using
I am new in iPhone development and Objective-C. I have RootViewController and DetailViewController. I
I am a relatively new iPhone/objective-c programmer and I have an issue that makes
I'm very new to Objective-C and I'm trying to develop an iPhone app. My
I am new to iPhone development and Objective C. I have decided I would
I am a new iPhone developer learning Objective-C, and trying to build an iPhone
I am a new iPhone developer learning Objective-C, and am trying to dynamically calculate
i'm new with the iphone and objective c, so far, I have been able

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.