0

A @property can be set as strong, weak , assign , copy ... like

@property (copy, nonatomic) NSString *string;

@property (strong ,nonatomic) CustomClass *object;

@property (weak,nonatomic) id <CustomDelegate>delegate;

However, if

@property id <CustomDelegate>delegate; weak?strong?
@property (copy, nonatomic) NSString *string; strong?

If (weak,nonatomic) is abbreviated. What is the default value of an id? And other?

redent84
  • 18,901
  • 4
  • 62
  • 85
seguedestination
  • 419
  • 4
  • 19

2 Answers2

3

id is a reference to some random Objective-C object of unknown class, thus it's default attributes are:

@property (atomic, readwrite, strong) id value;

Note: delegates 99.999% of the time should be weak.

Lord Zsolt
  • 6,492
  • 9
  • 46
  • 76
3

Properties Are Atomic by Default

This means that the synthesized accessors ensure that a value is always fully retrieved by the getter method or fully set via the setter method, even if the accessors are called simultaneously from different threads.

Because the internal implementation and synchronization of atomic accessor methods is private, it’s not possible to combine a synthesized accessor with an accessor method that you implement yourself. You’ll get a compiler warning if you try, for example, to provide a custom setter for an atomic, readwrite property but leave the compiler to synthesize the getter.

For more detail you can read this article https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html

Thanks

baydi
  • 1,003
  • 6
  • 11