After I apply custom logic, next UI action crashes my app.

Posted by DanF on Stack Overflow See other posts from Stack Overflow or by DanF
Published on 2010-03-14T02:13:15Z Indexed on 2010/03/14 2:25 UTC
Read the original article Hit count: 239

Filed under:
|
|

I've got an team (eveningRoster) that I'm making a button add employees to. The team is really a relationship to that night's event, but it's represented with an AC.

I wanted to make sure an employee did not belong to the team before it adds, so I added a method to MyDocument to check first. It seems to work, the error logs complete, but after I've added a member, the next time I click anything, the program crashes. Any guesses why? Here's the code:

-(IBAction)playsTonight:(id)sender
{
NSArray *selection = [fullRoster selectedObjects];
NSArray *existing = [eveningRoster arrangedObjects];

//Result will be within each loop.
BOOL result;
//noDuplicates will stay YES until a duplicate is found.
BOOL noDuplicates = YES;
//For the loop:
int count;

for (count = 0; count < [selection count]; count++){
    result = [existing containsObject:[selection objectAtIndex:count]];
    if (result == YES){
        NSLog(@"Duplicate found!");
        noDuplicates = NO;
    }
}
if (noDuplicates == YES){
[eveningRoster addObjects:[fullRoster selectedObjects]];
    NSLog(@"selected objects added.");
[eveningTable reloadData];
    NSLog(@"Table reloaded.");
}

[selection release];
[existing release];
return;
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa