What is the difference between weak, unsafe_unretained, and assign in Objective-C?

Updated May 17, 2026

Short answer

weak auto-nils, unsafe_unretained does not, assign is for primitives.

Deep explanation

weak references are zeroed out when object deallocates. unsafe_unretained behaves like a dangling pointer if object is freed. assign is used for primitive types. unsafe_unretained is risky but sometimes used in performance-critical or legacy C-bridged code.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Objective-C interview questions

View all →