Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synthesised properties for primitive data types using ARC -- weak or assign?

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?

like image 414
Darren Findlay Avatar asked Oct 13 '11 14:10

Darren Findlay


People also ask

What are the characteristics of primitive data types?

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.

How are primitive data types stored?

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.

What is the difference between primitive and complex 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.


1 Answers

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.

like image 138
Rob Bajorek Avatar answered Oct 19 '22 23:10

Rob Bajorek