I have a NSMutableArray that I want to edit. I want to check if all the members belong to class QueueMember (which has a property rank), and if it does I want it to set the value of rank for each object to its index in the Array.
This is what I have now which does not work. I'm wondering if it doesn't work because *queue is a pointer?
-(void)makingRankEqualtoLocationInQueue:(NSMutableArray *)queue{
queue = [[NSMutableArray alloc]init];
for (int queueSizeCounter = 0; queueSizeCounter <queue.count; queueSizeCounter++) {
id obj = [queue objectAtIndex:queueSizeCounter];
if ([obj isKindOfClass:[QueueMember class]]) {
QueueMember *member = obj;
member.rank = queueSizeCounter;
[queue replaceObjectAtIndex:queueSizeCounter withObject:member];
} else {
[queue removeObjectAtIndex:queueSizeCounter];
}
}
}