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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:12:35+00:00 2026-05-24T17:12:35+00:00

Looking through the code apple generates for core data I found this bit of

  • 0

Looking through the code apple generates for core data I found this bit of code

[__persistentStoreCoordinator release], __persistentStoreCoordinator = nil;

I understand the purpose for it but is there any purpose for writing the code like this instead of just like this

[__persistentStoreCoordinator release];
__persistentStoreCoordinator = nil;

or is it just being clever?

  • 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-24T17:12:35+00:00Added an answer on May 24, 2026 at 5:12 pm

    It’s purely a stylistic choice, but one that expresses intent. In this case, it’s expressing the intent that the release and the nil assignment are one single “operation” and should be kept together. As two separate lines, you are free to insert lines between them, but as a single statement using the comma operator it takes far more work to split them up.

    It’s also helpful to the reader in that they don’t have to parse two separate lines, figure out what they’re doing, and understand that it’s just trying to clear out that ivar. Instead as one statement, the reader can quickly recognize this pattern (once they’ve seen it a few times) and it produces less cognitive load on the user. For example, here’s a -dealloc using separate statements

    - (void)dealloc {
        [_foo release];
        _foo = nil;
        [_bar release];
        _bar = nil;
        [_blah release];
        _blah = nil;
        [_baz release];
        _baz = nil;
        [super dealloc];
    }
    

    Here’s the equivalent:

    - (void)dealloc {
        [_foo release], _foo = nil;
        [_bar release], _bar = nil;
        [_blah release], _blah = nil;
        [_baz release], _baz = nil;
        [super dealloc];
    }
    

    Not only is this fewer lines of code, but the pattern is immediately obvious to the reader. It also looks more aesthetically pleasing, with every line being a method call followed by a nil assignment.

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

Sidebar

Related Questions

I'm looking through some code for learning purposes. I'm working through this portion of
So I'm looking through some code, and I see this: class whatever { public:
I was looking through a code tutorial just now, and found something interesting --
Sometime when looking through code, I see many methods specify an annotation: @SuppressWarnings(unchecked) What
I have been looking through code for the last 3 days, and the original
Looking through some code I came across the following code trTuDocPackTypdBd.update(TrTuDocPackTypeDto.class.cast(packDto)); and I'd like
I have been looking through some code on an open source project recently and
I was looking through someone's code one day and I was annoyed how they
I was looking through Mozilla's JS in JS code and came across the snarf
I'm running some code through FxCop and am currently looking at clearing all of

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.