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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:20:51+00:00 2026-06-08T08:20:51+00:00

Is it possible to add a zeroing weak ref (in the ARC sense, not

  • 0

Is it possible to add a zeroing weak ref (in the ARC sense, not GC) instance variable to a class created using the runtime? If so how?

There is a function called class_setWeakIvarLayout() which seems to be related to this but the documentation (both for this function and the non-weak counterpart) is very thin unfortunately.

  • 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-08T08:20:53+00:00Added an answer on June 8, 2026 at 8:20 am

    class_setWeakIvarLayout() is used under GC. I’m not sure it is used under ARC at all. In any case, you can’t change the layout of a class at runtime, including adding arbitrary instance variables (though you can add ivars to a class and recompile without recompiling subclasses because of the modern runtime).

    See Associated objects. They provide most of what you want, maybe all (I’m not sure if zeroing-weak is supported directly — not, you’ll need to find an alternative solution).

    http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocAssociativeReferences.html


    Ahh — OK. Thanks for the clarification. I’m not sure if you can dynamically set the zeroing-weak ARC behaviors via API. The source for the runtime and compiler are available, though.

    Note that you can pretty easily fake zeroing weak under non-ARC environments by setting up a class that implements -dealloc to do whatever cleanup you need, associating instances with objects that need to trigger said cleanup on deallocation and making sure nothing else retains the object that has the custom -dealloc notification hook. It is a bit fragile, but it works.

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

Sidebar

Related Questions

Is it possible to add or remove slides in runtime using FlexSlider ?
how is it possible to add EntityObject instance into ObjectContext? I do not want
I want to add a simple panel to a dialog created using Visual Studio
Is it possible to add a new property to an anonymous type instance after
is it possible to add a notification to the lockscreen that will not disappear?
is it possible to add an instance of a java application as a child
Is it possible to add a event to the domain service class? I have
Is it possible to add attributes at runtime or to change the value of
I created dynamic list using android phonegap application.Now I want to add scrollbar for
Is it possible to add a computer remotely to a domain using PowerShell v2.0?

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.