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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:19:20+00:00 2026-06-04T04:19:20+00:00

I am currently playing around with ARC a bit to get some things figured

  • 0

I am currently playing around with ARC a bit to get some things figured out, before starting to do the actual work. I did setup this code:

NSNumber* n = [[NSNumber alloc] initWithInt:3];
__weak NSNumber* weakN = n;
n = nil;
NSLog(@">>>: %@ %@", n, weakN);

I expected n and weakN to be nil, as n = nil; should trigger a release in my eyes? Unfortunately it doesn’t. The output is “>>>: (null) 3”. What am I missing here?

Another thing is, that I am pretty sure, the below code was giving me a hard time when starting with arc:

__weak NSNumber* weakN2 = [[NSNumber alloc] initWithInt:3];
NSLog(@">>>: %@", weakN2);

I am pretty sure, I’ve had some problems with similar code, as arc would release the object straight after initialization, as there is no strong reference to the object. Unfortunately, the output of the above is “>>>: 3”.

It would be great to get some clarification on this stuff. I am clearly missing something here!

Best regards,
Michael

  • 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-04T04:19:22+00:00Added an answer on June 4, 2026 at 4:19 am

    In addition to what kevboh said, it’s also rather pointless to create weak references to simple immutable Foundation objects like NSNumber. For performance reasons, Foundation might well vend you a cached object instead of creating an entirely new one. And if it doesn’t now, then it might in some future release.

    The upshot is that you’re probably not the sole owner of the object returned by [[NSNumber alloc] initWithInt:3], no matter what you think.

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

Sidebar

Related Questions

I'm currently playing around with some app ideas using AirPlay mirroring and a second
I've got a bit of fettish for language design and I'm currently playing around
I am currently playing around with the idea of having history tables for some
I'm currently playing a bit around with scheme, and I've been stuck for quite
I am currently playing around with different scraping techniques and found out, that it
I'm currently playing around with tipfy on Google's Appengine and just recently ran into
I am currently playing around with Haskell basics and stumbled upon the following use
I'm am currently playing around with the third party facial recognition api from face.com.
I am currently playing around with chrome extensions. I would like to catch google
I am currently learning about basic networking in java. I have been playing around

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.