Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Sorting an array containing mantle model as object

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 384
    Comment on it

    Hi all,

    To sort an mantle array containing mantle model as object ,You can easily sort by multiple keys by adding more than one to the array. Using custom comparator-methods is possible as well.

        NSSortDescriptor *sortDescriptor;
        sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"departureTime"
                                                     ascending:YES];
        NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
       //busses is a temporary array used to hold sorted array
        busses = [self.tripArray.data.oneWay.buses sortedArrayUsingDescriptors:sortDescriptors];
        [self.ticketsTableView reloadData];
    

    In busses array , mantle model contain key departureTime and in above code we are sorting mantle array in ascending order

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: