سؤال

I have a NSSet relationship within my core data model with routinedet being the 1-to-many relationship

I am recalling the 'detail' view using the following which works fine and displays the data within a uitableview.

NSArray* array=[self.routine.routinedet allObjects];
    RoutinesDetails* det=[array objectAtIndex:indexPath.row];
    cell.textLabel.text=det.name;

I am trying to add the ability to reorder and need to sort my method in

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
      toIndexPath:(NSIndexPath *)toIndexPath {

I am not sure as to what I should have here to update the array and add the ability to permanently sort it. Is there a quick fix or do I need to change my core data model to include a displayOrder attribute and sort it that way?

هل كانت مفيدة؟

المحلول

If you're not using iCloud Core Data syncing you might be able to use an NSOrderedSet. Otherwise, yes, you'll have to manually store the ordering, either in the Core Data model of externally.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top