ARC Strong property Enumeration Error

Eric picture Eric · Jan 23, 2012 · Viewed 8.8k times · Source

I have the following code and am getting this error before compiling:

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

for (NSString *name in array){
        @try {
            S3ObjectController *localS3 = [[S3ObjectController alloc]init];
            name = localS3.stringProperty;
}

In this S3ObjectController class, I have the property declared like this:

@property (nonatomic, strong)  NSString *stringProperty;

How should I change the property? I thought I was declaring it strong?

Answer

Stuart picture Stuart · Jan 23, 2012

It means declare the fast enumeration variable strong, not your instance variable:

for (NSString __strong *name in array) {
    @try {
        S3ObjectController *localS3 = [[S3ObjectController alloc]init];
        name = localS3.stringProperty;
    }
}