Objective-C Language Properties

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • @property (optional_attributes, ...) type identifier;
  • @synthesize identifier = optional_backing_ivar;
  • @dynamic identifier;

Parameters

AttributeDescription
atomicImplicit. Enables synchronization in synthesized accessor methods.
nonatomicDisables synchronization in the synthesized accessor methods.
readwriteImplicit. Synthesizes getter, setter and backing ivar.
readonlySynthesizes only the getter method and backing ivar, which can be assigned directly.
getter=nameSpecifies the name of getter method, implicit is propertyName.
setter=nameSpecifies the name of setter method, implicity is setPropertyName:. Colon : must be a part of the name.
strongImplicit for objects under ARC. The backing ivar is synthesized using __strong, which prevents deallocation of referenced object.
retainSynonym for strong.
copySame as strong, but the synthesized setter also calls -copy on the new value.
unsafe_unretainedImplicit, except for objects under ARC. The backing ivar is synthesized using __unsafe_unretained, which (for obejcts) results in dangling pointer once the referenced object deallocates.
assignSynonym for unsafe_unretained. Suitable for non-object types.
weakBacking ivar is synthesized using __weak, so the value will be nullified once the referenced object is deallocated.
classProperty accessors are synthesized as class methods, instead of instance methods. No backing storage is synthesized.
nullableThe property accepts nil values. Mainly used for Swift bridging.
nonnullThe property doesn’t accept nil values. Mainly used for Swift bridging.
null_resettableThe property accepts nil values in setter, but never returns nil values from getter. Your custom implementation of getter or setter must ensure this behavior. Mainly used for Swift bridging.
null_unspecifiedImplicit. The property doesn’t specify handling of nil values. Mainly used for Swift bridging.


Got any Objective-C Language Question?