2

Code:

@property (nonatomic, retain) BOOL val;

Error:

Property with ‘retain(or Strong)’ attribute must be of object type

I want to use this bool object in another class. I am creating it in .h file

Cœur
  • 37,241
  • 25
  • 195
  • 267
Smit Saraiya
  • 391
  • 1
  • 5
  • 26

2 Answers2

3

BOOL is a primitive type (thus not a pointer, so no memory management).

You declare the property this way :

@property (nonatomic) BOOL val;

(you can also explicitly write assign instead of strong/retain)

Tanguy G.
  • 2,143
  • 19
  • 18
2

Use the assign attribute, which is the default for BOOL anyway:

@property (nonatomic, assign) BOOL val;
trojanfoe
  • 120,358
  • 21
  • 212
  • 242