Program runs forever when SortDescriptors are added


When I add the NSSortDesciptors, my program builds fine but then runs forever, without the descriptors it runs in a normal fashion.

// main.m
// BMITime
// Created by Dorman John on 7/27/12.
// Copyright © 2012 MyCompanyName. All rights reserved.

#import <Foundation/Foundation.h>
#import “Employee.h”
#import “Asset.h”

int main(int argc, const char * argv[])

@autoreleasepool {
    //                          Create an array of Employee objects
    NSMutableArray *employees = [[NSMutableArray alloc] init];
    for (int i = 0; i<10; i++)  {
        //                      Create an instance of Employee
        Employee *person = [[Employee alloc] init];
        //                       Give the instance variable interesting values
        [person setWeightInKilos:90 +i];
        [person setHeightInMeters:1.8-i/10.0];
        [person setEmployeeID:i];
        //                      Put the employee in the employees array
        [employees addObject:person];
    NSMutableArray *allAssets = [[NSMutableArray alloc] init];
    //                          Create 10 assets
    for (int i = 0; i < 10; i++)  {
        //                      Create an asset
        Asset *asset = [[Asset alloc] init];
        //                      Give it an interesting label
        NSString *currentLabel = [NSString stringWithFormat:@"Laptop %d", i];
        [asset setLabel:currentLabel];
        [asset setResaleValue:i * 17];
        //                      Get a random number between 0 and 9 inclusive
        NSUInteger randomIndex = random() % [employees count];
        //                      Find that employee
        Employee *randomEmployee = [employees objectAtIndex:randomIndex];
        //                      Assign the assset to the employee
        [randomEmployee addAssetsObject:asset];
        [allAssets addObject:asset];
    NSSortDescriptor *voa = [NSSortDescriptor sortDescriptorWithKey:@"valueOfAssets"
    NSSortDescriptor *ei = [NSSortDescriptor sortDescriptorWithKey:@"employeeID"
    [employees sortUsingDescriptors:[NSArray arrayWithObjects: voa, ei, nil]];
    NSLog(@"Employees: %@", employees);
    NSLog(@"Giving up ownership of one employee");
    [employees removeObjectAtIndex:5];
    NSLog(@"allAssets: %@", allAssets);
    NSLog(@"Giving up ownership of array");
    allAssets = nil;
    employees = nil;

return 0;



Hmm. Interesting!

Would you post your Employee.m and Asset.m files? I suspect that one of your accessor methods is calling itself.