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

  • Home
  • SEARCH
  • 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 152173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:34:33+00:00 2026-05-11T09:34:33+00:00

I don’t plan to write applications without IB, I’m just in the process of

  • 0

I don’t plan to write applications without IB, I’m just in the process of trying to learn more about programming.

How can I get a single instance of my AppController class at startup? (It’s normally loaded from the nib.) And can you clear up the use of +initialize and -init? If I understand, +initialize is called on all classes at startup. How can I use this to create an instance of my AppController with instance variables that make up my interface?

Hope that makes sense, and thanks for any help.

  • 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. 2026-05-11T09:34:34+00:00Added an answer on May 11, 2026 at 9:34 am

    +initalize is sent to a class the first time it or one of its subclasses receives a message for the first time. So, when you do:

    instance = [[[YourClass alloc] init] autorelease]; 

    That alloc message triggers initialize.

    If you do the same thing with a subclass:

    instance = [[[SubclassOfYourClass alloc] init] autorelease]; 

    That alloc message will trigger +[YourClass initialize] the same way the other one did (prior to also triggering +[SubclassOfYourClass initialize]. But only one of these will do it—each class’s initialize never gets called more than once. (Unless you call it yourself with [super initialize] or [SomeClass initialize]—so don’t do that, because the method won’t be expecting it.)

    -init, on the other hand, initializes a new instance. In the expression [[YourClass alloc] init], you are personally sending the message directly to the instance. You may also call it indirectly, through another initializer ([[YourClass alloc] initWithSomethingElse:bar]) or a convenience factory ([YourClass instance]).

    Unlike initialize, you should always send init (or another initializer, if appropriate) to your superclass. Most init methods look roughly like this:

    - (id) init {     if ((self = [super init])) {         framistan = [[Framistan alloc] init];     }     return self; } 

    Details differ (this method or the superclass’s or both may take arguments, and some people prefer self = [super init] on its own line, and Wil Shipley doesn’t assign to self at all), but the basic idea is the same: call [super init[WithSomething:…]], make sure it didn’t return nil, set up the instance if it didn’t, and return whatever the superclass returned.

    This implies that you can return nil from init, and indeed you can. If you do this, you should [self release], so that you don’t leak the failed object. (For detecting invalid argument values, an alternative is NSParameterAssert, which throws an exception if the assertion fails. The relative merits of each are beyond the scope of this question.)

    How can I use this to create an instance of my AppController with instance variables that make up my interface?

    The best way is to do it all in main:

    int main(int argc, char **argv) {     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];      AppController *controller = [[[AppController alloc] init] autorelease];     [[NSApplication sharedApplication] setDelegate:controller]; //Assuming you want it as your app delegate, which is likely     int status = NSApplicationMain(argc, argv);      [pool drain];     return status; } 

    You’ll do any other set-up in your application delegate methods in AppController.

    You already know this, but for anyone else who reads this: Nibs are your friend. Interface Builder is your friend. Don’t fight the framework—work with it, and build your interface graphically, and your application will be better for it.

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

Sidebar

Ask A Question

Stats

  • Questions 110k
  • Answers 110k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I see room for improvement in a couple spots in… May 11, 2026 at 9:38 pm
  • Editorial Team
    Editorial Team added an answer Labels are pieces of text next to input fields -… May 11, 2026 at 9:38 pm
  • Editorial Team
    Editorial Team added an answer I reckon the problem is that you don't add the… May 11, 2026 at 9:38 pm

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I don't know when to add to a dataset a tableadapter or a query
I don't edit CSS very often, and almost every time I need to go
I don't understand where the extra bits are coming from in this article about
I don't want PHP errors to display /html, but I want them to display

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.