str = @"abcd"
, , , __weak
.
, @"abcd"
. . retain
release
. , . , __weak
str
nil, . abcd
.
, clang , ( - , @[a, b, c]
). . :
static bool checkUnsafeAssignLiteral(Sema &S, SourceLocation Loc,
Expr *RHS, bool isProperty) {
RHS = RHS->IgnoreParenImpCasts();
Sema::ObjCLiteralKind Kind = S.CheckLiteralKind(RHS);
if (Kind == Sema::LK_String || Kind == Sema::LK_None)
return false;
S.Diag(Loc, diag::warn_arc_literal_assign)
<< (unsigned) Kind
<< (isProperty ? 0 : 1)
<< RHS->getSourceRange();
return true;
}
, NSArray
, :
... , str = [[NSString alloc] init]
, , [[NSString alloc] init]
- , .
, [[NSString alloc] init]
, str
nil. , -[NSString init]
. .
__weak NSString *str;
str = [[NSString alloc] init];
NSLog(@"%ld %p [%@]", CFGetRetainCount((__bridge CFTypeRef)str), str, str);
:
2018-01-24 01:00:22.963109-0600 test[3668:166594] 1152921504606846975 0x7fffe55b19c0 []
, 1152921504606846975 - - , .