NSSortDescriptor - Sort descriptor based on another array

前端 未结 3 845
独厮守ぢ
独厮守ぢ 2021-01-13 05:39

I hava a core data application. And I want to fetch one kind of object, User. User have the property userId.

I have another a

3条回答
  •  不知归路
    2021-01-13 06:12

    Use this idea which i use to sort message id if it is added to DB

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"message_id" ascending:NO selector:@selector(localizedStandardCompare:)];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
        [request setSortDescriptors:sortDescriptors];
        request.returnsObjectsAsFaults=NO;
     NSError *error = nil;
        NSArray *results = [managedObjectContext executeFetchRequest:request error:&error];
    

提交回复
热议问题