objcio / articles

All current objc.io articles
593 stars 122 forks source link

Fix __weak keywork position mistake. #102

Open ychang-brightcove opened 9 years ago

ychang-brightcove commented 9 years ago

Based on Apple's doc: Transitioning to ARC Release Notes, __weak is type qualifier. So, the correct position of __weak is Type * __weak weakPtr, which is weakPtr is a weak pointer points to a variable with Type, instant of __weak Type * notWeakPtr, which is notWeakPtr is a pointer points to a weak variable with Type.

Since const is type qualifier too, replacing __weak by const is a easy way to verify it. The following is the example to show the difference: Type * const constPtrand const Type * ptrToConstType.