xobjc icon indicating copy to clipboard operation
xobjc copied to clipboard

nonatomic per default?

Open steipete opened this issue 14 years ago • 4 comments

In the Xcode4 version, all my properties miss the "nonatomic" declaration, and if i add it manually via the XPROPERTY flag, the XASSIGN/XRETAIN is no longer honored. (nonatomic should be default, and

XRETAIN XPROPERTY(atomic) UIView *var

should emit

@property(xobjc nonatomic, retain) UIView *var;

instead of

@property(xobjc nonatomic) UIView *var;

steipete avatar Aug 27 '11 11:08 steipete

I thought this was a decision of requirements, therefore I made it configurable. Just comment out the second line in xobjc4.py.

NONATOMIC = ""
# NONATOMIC = "nonatomic, "

holtwick avatar Aug 27 '11 14:08 holtwick

Ah, great! It should be reflected in the README, and maybe nonatomic should be default?

steipete avatar Aug 27 '11 14:08 steipete

atomic means that it is thread safe, if I'm not wrong. This seems to be the more 'secure' setting, even if it's slower. However, maybe it should be easier to configure. Or we could add variants like XRETAIN and XRETAIN_ATOMIC or XRETAINA. What do you think?

holtwick avatar Aug 27 '11 14:08 holtwick

Yes, atomic is safer, but also slower - as I understand nonatomic is encouraged, only where thread access is used we should switch to atomic. I do like XRETAIN_ATOMIC and XASSIGN_ATOMIC - probably easier than parsing nonatomic out of XPROPERTY...

steipete avatar Aug 27 '11 14:08 steipete