How do I use set_associated_object when the property I want to add is an unsigned int (enum)?



Now I'm doing it like this, is it correct? Any risks? Thanks in advance.

-(void)setNetworkStatus:(unsigned int)object{
    objc_setAssociatedObject(self, @selector(networkStatus),
@(object), OBJC_ASSOCIATION_ASSIGN);
}

-(unsigned int)networkStatus{
    return (unsigned int)[objc_getAssociatedObject(self,
@selector(networkStatus)) integerValue];
}

I have changed OBJC_ASSOCIATION_ASSIGN to OBJC_ASSOCIATION_RETAIN_NONATOMIC in my code. Is there any problem?


Related to : How do I use set_associated_object when the property I want to add is an unsigned int (enum)?

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .