티스토리 뷰

http://stackoverflow.com/a/9860283

Nonatomic

nonatomic은 다중 threading 목적들에 사용된다. If we have set the nonatomic attribute at the time of declaration, then any other thread wanting access to that object can access it and give results in respect to multi-threading.

Copy

copy는 object가 가변적일때 사용된다. Use this if you need the value of the object as it is at this moment, and you don't want that value to reflect any changes made by other owners of the object. You will need to release the object when you are finished with it because you are retaining the copy.

Assign

Assign은 다소 copy와 반대다. When calling the getter of an assign property, it returns a reference to the actual data. Typically you use this attribute when you have a property of primitive type (float, int, BOOL...)

Retain

retain은 attribute가 object에 포인터일때 필요. The setter generated by @synthesize will retain (aka add a retain count to) the object. You will need to release the object when you are finished with it. By using retain it will increase the retain count and occupy memory in autorelease pool.

Strong

strong은 retain attribute 대신인데, Objective-C Automated Reference Counting (ARC)의 부분으로. ARC 아닌 code 에서는 단지 retain의 동의어일 뿐.

iOS strong 과 weak 배우기위한 좋은 사이트는 아래의 링크로
http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1

Weak

weak은 strong과 유사하나 참조 카운트를 1 이상 증가시키지 않을것이다. It does not become an owner of that object but just holds a reference to it. If the object's reference count drops to 0, even though you may still be pointing to it here, it will be deallocated from memory.

위 링크는 Weak and Strong 관련한 좋은 정보들을 포함하고 있다.

댓글