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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:07:44+00:00 2026-05-26T08:07:44+00:00

Apple have recently published Transitioning to ARC Release Notes , a document that explains

  • 0

Apple have recently published Transitioning to ARC Release Notes, a document that explains ARC and tackles some of the issues of converting non-ARC code to ARC. In the first version of these notes, they mention the following:

If you you [sic] find that you must implement custom retain or release methods, then you must also implement the following method in your class:

-(BOOL)supportsWeakPointers { return NO; }

This method will prevent weak pointers from being formed to your objects. You are strongly encouraged to find a solution that doesn’t require implementing your own retain and release methods instead of doing this.

Consider this scenario:

  1. Declare a class called MyClass and implement -supportsWeakPointers as returning NO. Tell Xcode to compile the corresponding implementation file with -fno-objc-arc. For good measure, declare the class as NS_AUTOMATED_REFCOUNT_WEAK_UNAVAILABLE and override -release and -retain.

  2. In MainMenu.xib, place a top-level object of type MyClass.

  3. In the application delegate, specify a weak IBOutlet property for an instance of MyClass:

     @property (weak) IBOutlet MyClass *myObject;
    

    and connect it to the corresponding object in the nib file.In this case, since the object is a top-level nib object and File’s Owner is of type NSApplication, that object is created with an extra reference count, which means it should stay alive until an explicit release. With ARC, this means calling CFRelease() since ARC forbids sending a release message.

My question is twofoldthreefold:

  1. Why is -supportsWeakPointers an instance method instead of a class method? Is there any case where a class can have instances that differ with respect to allowing weak references?

  2. -supportsWeakPointers is never sent to the MyClass instance created when the nib file is loaded; why? I’ve tested this by both placing an NSLog() inside of it and adding a symbolic breakpoint to Xcode. Also, I never get a

     cannot form weak reference to instance (0x???) of class MyClass
    

    message when I run the program.

  3. The top-level nib object of type MyClass should never get deallocated during the program execution because my program never releases it. However, the corresponding weak outlet is nil after the nib file has been loaded; why? Changing the outlet property to strong results in the object being different from nil but this shouldn’t be necessary.Doesn’t really happen; sorry. I was testing a version that was assigning an fresh new object that wasn’t really used, so ARC correctly assigned nil to the property.

A sample project that reproduces this error is available here.

I’m using Xcode 4.2 with Apple LLVM Compiler 3.0 on a Mac OS X v10.7.2 box.

  • 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-26T08:07:45+00:00Added an answer on May 26, 2026 at 8:07 am
    1. Consider the case of a class with both a “shared” or “default” instance and other instances (e.g. NSFileManager). Your shared instance likely has different weak pointer behavior from the other allocatable instances. There are times where different instances may want different weak pointer behavior. That having been said, if this is the case something’s probably Not Quite Right.

      (Answer 1. was originally written by Chris Parker. I’m adding it to Joshua’s answer so that the accepted answer is complete.)

    2. In your sample changing supportsWeakPointers to allowsWeakReference as defined in NSObject.h causes things to behave as one would expect. It’s marked as NS_DEPRECATED but it doesn’t look like there is an alternative in the SDK yet.

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

Sidebar

Related Questions

I have data that looks like this: entities id name 1 Apple 2 Orange
We have an application that performs auto-updates. Until recently, we haven't run into any
I have recently started a new job in a company that depends heavily in
We have a browser plugin that has recently been ported to the Mac. During
Recently I have been tasked with creating an application for a business that basically
We have recently discovered that when we run a lot of different processes on
I have noticed on some Apple sites like: http://help.apple.com/mobileme/index.html#mm5b08c671 they have custom scrollbars using
I have app that exports data in CSV. Recently I added Open In... feature
I've recently had some issues implementing a zooming feature into a painting application. Please
I have recently read Apple's sample code for MVCNetworking written by Apple's Developer Technical

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.