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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:51:41+00:00 2026-06-09T18:51:41+00:00

I understand that this may seems a very basic question, but I always thought

  • 0

I understand that this may seems a very basic question, but I always thought that explaining (and understanding) basic question is the key to build clean and working code.
I have the following fragment of code in a CoreData entity:

-(BOOL)validateForInsert:(NSError *__autoreleasing *)error {
    [super validateForInsert:error];
    return [self validateInternal:error];
}

-(BOOL)validateInternal:(NSError *__autoreleasing *)error {
  // checking attributes and build userInfo error
  if(anyErrors) {
    *error = [NSError errorWithDomain:appDomain code:200 userInfo:details];
    return NO;
  }
  return YES;
}

by running ‘analyze’ in Xcode I get the famous ‘potential null dereference’ when creating error. While the compiler is not giving any alert, and the code has always worked.
This could be a question too, why the compiler doesn’t warn me about that ?

But coming to the code, I perfectly know the solution, which is to check if (error != nil), but I am quite lost at this.
The question start at the beginning, at the meaning of NSError *_autoreleasing* , why the surrounding star ? Which should be a pointer to a pointer ?

Supposing I would like to call the validateForInsert: by myself, how can I build an *_autoreleasing* object ?

The following question, I suppose is related to the question above: if I am building the *error from scratch, why am I suppose to check if nil first ?

Last but not least, the code works fine, the errors get intercepted, could you please spot a case that can have it fail or crash ? As I said I am using CoreData, a generic example would be fine, but another related to CoreData is appreciated.

thanks

  • 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-06-09T18:51:42+00:00Added an answer on June 9, 2026 at 6:51 pm
    *error = [NSError errorWithDomain:appDomain code:200 userInfo:details];
    

    is syntactically correct, therefore the compiler does not warn. The Analyzer detects that this will crash at runtime if error = NULL, i.e. if you call

    [myObj validateForInsert:NULL];
    

    If you call

    NSError *error;
    [myObj validateForInsert:&error];
    

    then you pass the address of error, therefore you pass a variable of type NSError * *.

    The __autoreleasing modifier is a hint to the ARC compiler that the object assigned to error is an autoreleased object.

    You can declare a variable to be autoreleasing with

    NSError * __autoreleasing error;
    [myObj validateForInsert:&error];
    

    but normally you do not care. ARC just generates the correct code.

    For details, read the Transitioning to ARC Release Notes. There are also lots of answers on this topic on stackoverflow.

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

Sidebar

Related Questions

I understand that this question may be subjective, this is why I need an
This may seem like a basic/stupid/obviously-answered question, but I wanted to check: why use
This may seem like a very basic question, since I'm not familiar with jQuery,
I understand that this question could be answered with a simple sentence and that
I am very new to Silverlight development. I understand that this is client side
I understand that 2 options are available: Non-persistent Persistent But what does this actually
This is a short question. At some point my thread understand that it should
I think this is a very simple question, but I’m new to programming so
I am new to regular expression and this may be a very easy question
This is very much a repeat of an old question that is available here:

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.