Link to home
Start Free TrialLog in
Avatar of jmc430
jmc430

asked on

Removing Item from Array List

Greetings!

I'm having some trouble with my code .. I am trying to suppress the repetitions of a department name in an array list.

I am setting a boolean within the if statement, to set isDUPLICATE=false when deps.equals(depL.departmentName())

However, whenever I set the boolean, it sets it for the entire function, rather than just within the if statement ..

Basically, I would like it to only be set for the conditional when the criteria is met .. and I want the boolean to be reset to true afterwards (in order to show the rest of the list of depts).  I have NSLOg.out.appendln(Printf) statements everywhere showing the correct boolean values, but for some reason all the values being returned on my HTML page are all either true or false, instead of set as particular to the values in my printf statements.

Please help!  

This is my relevant code:

public NSArray getAllDepartments(){

   if (results.count()==2){
    Department depFirst = (Department)a.objectAtIndex(0);
    Department depLast = (Department).b.objectAtIndex(1);

   if (!(depFirst .divisionName().equals(depLast .divisionName())){
    if((deps!=null)&&(deps.equals(depLast .departmentName())){
     isDUPLICATE=false;

}
   deps=(depLast.departmentName());

   NSArray originalListWithDuplicates=ms.allObjects();
   EOSortOrdering ordering1=new EOSortOrdering("departmentName", EOSortOrdering.CompareAscending);
   NSMutableArray sortOrdering=new NSMutableArray();
   sortOrdering.addObject(ordering1);
   return EOSortOrdering.sortedArrayUsingKeyOrderArray(originalListWithDuplicates,sortOrdering);
}

}

}
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmc430
jmc430

ASKER

thanks CEHJ!

=)
:-)