When I do something simialr to the following I get an error saying
for (UIView* att in bottomAttachments) {
if (i <= [cells count]) {
att = [[UIView alloc] extraStuff]
}
}
Fast Enumeration variables cannot be modified in ARC: declare __strong
What does __strong
do and why must I add it?
source
As Martin noted in a comment, it's worth noting that even with a
__strong
variable, by reassigning it you won't modify the array itself, but you'll just make the local variable point to a different object.Mutating an array while iterating on it is generally a bad idea in any case. Just build a new array while iterating and you'll be fine.
Why are you assigning a new value to that pointer anyway? Are you trying to replace an object in the array? In that case you need to save what you want to replace in a collection and do it outside the enumeration since you can't mutate an array while enumerating.