I was wondering what is the correct way to write synthesised properties for primitive data types (like bool
) when ARC is enabled.
I used to use this before ARC:
@property(assign) bool isOn;
But it is my understanding (maybe wrong) that you shouldn't use assign
when ARC is enabled. I tried replacing this with weak
but I get the error -
Property of "weak" attribute must be of type object.
Should I continue to use assign
?
Primitive data are only single values; they have no special capabilities. A variable is a name for a location in memory used to store a data value. We use variables to save and restore values or the results of calculations.
Thus, you have seen that all primitive data types are stored on the stack, and in the case of reference type, stack holds a pointer to the object on the heap. Here, we have described only basic ideas related to the concept of memory allocation of data types.
In FHIR, the data types are divided into 'primitive' and 'complex' data types. The primitive data types are types like string , integer , boolean , etc. that can take a single value. The complex types consist of multiple values grouped together.
Assign
is fine. ARC stands for "Automatic Reference Counting", and primitive data types do not have reference counts.
Weak
failed because there is no object, nor any references for ARC to manage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With