2010-12-19 97 views
0

我想對NSString的數組進行排序,但我不確定如何實際將參數傳遞給@selector方法。這就是爲什麼我試圖做使用具有兩個參數的自定義選擇器排序數組

//After the optional: id like to pass a UITextField.text but not sure how. 
NSArray *sortedSection = [wordSection sortedArrayUsingSelector:@selector(sortValue:optional:)]; 

這是我試圖使用的方法。

- (NSComparisonResult) sortValue:(NSString *)otherString optional:(NSString *)otherLetters; 

任何幫助,非常感謝。

回答

2

這會幫助嗎?

NSArray *tm; 
NSSortDescriptor *name = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; 
NSSortDescriptor *age = [NSSortDescriptor sortDescriptorWithKey:@"age" ascending:YES]; 
[tm sortedArrayUsingDescriptors:[NSArray arrayWithObjects:name, age, nil]]; 

並沒有真正理解什麼是wordSection,你喜歡什麼排序,並會在UITextField.text

什麼