Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBJC_ASSOCIATION_COPY should be viewed as a strong reference? #85

Open
Kam-To opened this issue Sep 24, 2019 · 0 comments
Open

OBJC_ASSOCIATION_COPY should be viewed as a strong reference? #85

Kam-To opened this issue Sep 24, 2019 · 0 comments

Comments

@Kam-To
Copy link

Kam-To commented Sep 24, 2019

OBJC_ASSOCIATION_COPY and OBJC_ASSOCIATION_COPY_NONATOMIC specifies that the associated object is copied, which means that the object has a strong reference to the associated value (in my understanding).

Is that any special consideration to ignore this reference in the function below? 🤔

static void fb_objc_setAssociatedObject(id object, void *key, id value, objc_AssociationPolicy policy) {
  {
    std::lock_guard<std::mutex> l(*_associationMutex);
    // Track strong references only
    if (policy == OBJC_ASSOCIATION_RETAIN ||
        policy == OBJC_ASSOCIATION_RETAIN_NONATOMIC) {
      _threadUnsafeSetStrongAssociation(object, key, value);
    } else {
      // We can change the policy, we need to clear out the key
      _threadUnsafeResetAssociationAtKey(object, key);
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant