I NSArray
string
together do not follow the object patterns, such as:
DCAZ X
when I tried to solve the same array
ascending order, I:
Adeediaks Z .
This is not the result, I need to get a pattern similar to the reference array. I'm not sure how to do this either using NScomparisonResult
or NSSortDescriptor
.
The second array
can not be exactly the same way, but I need the same order. For example, maybe I have a DX A array based on the reference
I need to get DAX
UPDATE:.
OK, so here's my code:
- (PFQuery *) queryForTable {PFQuery * query = [PFQuery queryWithClassName: self.parseClassName]; // This reference array NSArray * label = [@ "Cafe da Manha", @ "Meio da Manha", @ "AlmoƧo" @ "Meio da Tarde", @ "Last da Tarde", @ "Jantar", @ "POS Treino"]; NSSortDescriptor * descriptors = [NSSortDescriptor sortDescriptorWithKey: @ "refeicao" Ascending: Yes comparator: ^ NSComparisonResult (ID obj1, ID obj2) {NSUInteger index1 = [label indexOfObject: obj1]; NSUIENTEGER INDEX 2 = [label index OF object: OZG 2]; Index 1 - Index 2; }]; [Query order bySortDescriptor: descriptor]; Return query; }
I have an array of PFObject
, which I need to order by the key refeicao
.
You can tie will write your Comparative Law (which descriptors of a kind because you Call it NSComparator
).
This method will need to search for 2 strings compared to your reference array and use index position for comparison. The actual value will not be compared, everything is about the position of the corresponding string in the reference array.
Comments
Post a Comment