1

I was watching the F8-2016 Building iOS Tooling at Facebook Scale video, when I've noticed an interesting code part at 7:01.

Facebook defined a static constant in Objective-C this way:

static __unsafe_unretained NSString * const kAuthorKey = @"AUTHOR";

Up to now, I declared my static constants the same way, but without the __unsafe_unretained. Without this modifier, the constant will be strong, but since it exists always during the application run, it doesn't matter if it is strong or __unsafe_unretained.

Am I missing something? Do Facebook has any reason to use __unsafe_unretained?

Infinite Possibilities
  • 7,415
  • 13
  • 55
  • 118
  • 1
    The only think I can think of is that Facebook was trying to support a platform where `__weak` didn't exist (iOS 4 and below). Or because `const` specifies that this pointer is constant pointer to a heap address where the memory will never change, and it's safe to use `__unsafe_unretained` – JAL Apr 26 '16 at 20:40
  • 1
    Or maybe Facebook is working in a non-arc environment. – JAL Apr 26 '16 at 20:48
  • 1
    Constant strings are never deallocated anyways, so it doesn't matter much. – Carl Lindberg Apr 27 '16 at 02:28

0 Answers0