How to set a boolean type property in objective C class How to set a boolean type property in objective C class objective-c objective-c

How to set a boolean type property in objective C class


You can declare this way also.

@property (assign) BOOL locationUseBool;

Basically, if you say nonatomic, and you generate the accessors using @synthesize, then if multiple threads try to change/read the property at once, badness can happen. You can get partially-written values or over-released/retained objects

In a multi-threaded program, an atomic operation cannot be interrupted partially through, whereas nonatomic operations can.


@property (nonatomic, assign) BOOL locationUseBool;

No asterisk, no copy, no retain.


This one worked for me.

@property (nonatomic) BOOL locationUseBool;

There is not asterisk * symbol in property declaration. Also, use of 'assign' is optional.