Sortuj NSArray za pomocą obiektów niestandardowych

W moim projekcie Xcode mam następujące klasy:

Adres

@interface LDAddress : NSObject{
    NSString *street;
    NSString *zip;
    NSString *city;
    float latitude;
    float longitude;
}

@property (nonatomic, retain) NSString *street;
@property (nonatomic, retain) NSString *zip;
@property (nonatomic, retain) NSString *city;
@property (readwrite, assign, nonatomic) float latitude;
@property (readwrite, assign, nonatomic) float longitude;

@end

Lokalizacja

@interface LDLocation : NSObject{
    int locationId;
    NSString *name;
    LDAddress *address;
}
@property (readwrite, assign, nonatomic) int locationId;
@property (nonatomic, retain) LDAddress *address;
@property (nonatomic, retain) NSString *name;

@end

W podklasie UITableViewController istnieje NSArray zawierający wiele nieposortowanych obiektów LDLocations. Teraz chcę posortować obiekty NSArray rosnące na podstawie właściwościMiasto adresu LDAddress.

Jak mogę posortować tablicę za pomocą NSSortDescriptor? Wypróbowałem poniższe, ale aplikacja zrzuca podczas sortowania tablicy.

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Address.city" ascending:YES];
[_locations sortedArrayUsingDescriptors:@[sortDescriptor]];

questionAnswers(4)

yourAnswerToTheQuestion