When I do something simialr to the following I get an error saying
for (UIView* att in bottomAttachments) {
if (i <= [cells count]) {
att = [
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.
NSMutableDictionary * viewsToReplace = [[NSMutableDictionary alloc] init];
NSUInteger index = 0;
for(UIView * view in bottomAttachments){
if (i <= [cells count]) {
// Create your new view
UIView * newView = [[UIView alloc] init];
// Add it to a dictionary using the current index as a key
viewsToReplace[@(index)] = newView;
}
index++;
}
// Enumerate through the keys in the new dictionary
// and replace the objects in the original array
for(NSNumber * indexOfViewToReplace in viewsToReplace){
NSInteger index = [indexOfViewToReplace integerValue];
UIView * newView = viewsToReplace[indexOfViewToReplace];
[array replaceObjectAtIndex:index withObject:newView];
}