I have an object with a name Deliverythat has a set of objects associated with it Customer. Each delivery object also stores mainCustomerIdwhich is NSNumber*. I have an NSFetchedResultsController that is used to control the data source for UITableView. The problem is that I want to sort the NSFetchedResultsController according to the client’s lastName field (the client is again stored in the many-to-many relationship called customersin the object Delivery), where one of the clients in the set has customerId conforming to the Delivery MainCustomerId standard.
Delivery class looks like this (only relevant parts)
@interface Delivery : NSManagedObject
@property (nonatomic, retain) NSNumber * mainCustomerId;
@property (nonatomic, retain) NSSet *customers;
@end
The client class is as follows
@interface Customer : NSManagedObject
@property (nonatomic, retain) NSNumber * customerId;
@property (nonatomic, retain) NSString * lastName;
@property (nonatomic, retain) NSSet *deliveries;
@end
NSSortDescriptor, - (, , . , )
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"customers.AnyobjectInSet.lastName WHERE AnyobjectInSet.customerId == masterCustomerId ascending:YES];
, NSExpressions, , - , Cocoa (, @selector), mysql no Cocoa . , - , mysql.
select * from Delivery JOIN Customer ON Customer.customerId=Delivery.mainCustomerId ORDER BY Customer.lastName;
( , , , . ). .
.