Adding/removing object to mutable array
<p>I have <strong>allSpecialities</strong> array, and <strong>selectedSpecialities</strong> array. I'm downloading those arrays from the server, parse them to object and adding them to those arrays. Now, I want to check/uncheck some specialities. I've tried with <code>containsObject</code>, but that's not working, because those objects are not on the same memory location. This is code that I've done so far, and it's working, but I have problem how to add them to this array.
in <code>cellForRowAtIndexPath</code>:</p>

<pre><code>for (Speciality *specTemp in self.selectedSpecialities) {
        if (speciality.specialityId == specTemp.specialityId) {
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
            break;
        }
        else {
            cell.accessoryType = UITableViewCellAccessoryNone;
        }
    }
</code></pre>

<p>in <code>didSelect</code>:</p>

<pre><code>Speciality *speciality = [[Speciality alloc]init];
    speciality = self.allSpecialities[indexPath.row];
    NSMutableArray *tempSelectedSpecialities = [[NSMutableArray alloc]initWithArray:self.selectedSpecialities];
    int i=0;
    for (Speciality *tempSpeciality in tempSelectedSpecialities) {
        if (tempSpeciality.specialityId == speciality.specialityId) {
            [self.selectedSpecialities removeObjectAtIndex:i];
        }
        else {

        }
        i++;
    }

    [self.delegate companySpecialities:self.selectedSpecialities];
    [self.specialitiesTableView reloadData];
</code></pre>