Quantcast
Channel: HAPPY*TRAP » Objective-C
Viewing all articles
Browse latest Browse all 10

[Objective-C] ARC使用時のFast Enumeration(高速列挙)で取り出した要素を変更する

$
0
0


ARC使用時に、以下のようにFast Enumeration(高速列挙)で取り出した要素を変更しようとしたらエラーで怒られました。

for (NSString *name in names) {
    name = @"hoge";
}

Fast Enumeration Variables can’t be modified in ARC by default, declare the variable _strong to allow this

メッセージに従って要素にStrongを指定したら通してくれました。

for (NSString __strong *name in contents) {
    name = @"hoge";
}

環境
Mac OS X 10.8.2
Xcode 4.5

Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images