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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:22:57+00:00 2026-05-25T13:22:57+00:00

From the Mac OS X Application Programming Guide, Initializing a New Document (emphasis added):

  • 0

From the Mac OS X Application Programming Guide, “Initializing a New Document” (emphasis added):

If you override init, make sure that your override never returns nil.
Returning nil could cause a crash (in some versions of AppKit) or
present a less than useful error message. If, for example, you want to
prevent the creation or opening of documents under circumstances
unique to your application, override a specific NSDocumentController
method instead.

From Xcode’s auto-generated MyDocument.m:

- (id)init
{
    self = [super init];
    if (self) {
        // Add your subclass-specific initialization here.
        // If an error occurs here, send a [self release] message and return nil.
    }
    return self;
}

Why does Apple give conflicting advice here?

  • 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-25T13:22:58+00:00Added an answer on May 25, 2026 at 1:22 pm

    The general idiom is that -init may release self and return nil if an error occurs. The document you’re citing for “never return nil” is specifically talking about subclassing NSDocument. Basically, returning nil is fine in the general case, but it’s a bad idea for NSDocument specifically. The template file for MyDocument.m doesn’t know about the NSDocument case, it’s just giving you the general-purpose template for the -init method.

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

Sidebar

Related Questions

I'm teaching myself Objective-C from a book ( Cocoa programming for mac OS X
I have a mac with a custom PHP 5 install that built from about
as a Mac outsider it seems that two popular programming languages on the Mac
My Cocoa (Mac) application deals with a file format that doesn't have a standardised
I'd like to pull a stream of PCM samples from a Mac's line-in or
How do I set up a shell script to execute from the Mac OSX
Is it possible to build a .dmg file (for distributing apps) from a non-Mac
On Mac OS X, you can create a zip archive from the Finder by
What are the differences from a developer point of view between Safari for Mac
How can I remove those annoying Mac OS X .DS_Store files from a Git

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.