开发者

Sort Array Using Custom Selector With Two Arguments

I'm tryi开发者_如何学Gong to sort an array of NSStrings but i'm unsure how to actually pass parameters into the @selector method. Here is why I'm trying to do

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

Here is the method I'm attempting to use.

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

Any help is greatly appreciated.


would this help?

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

didn't really understand what is in wordSection, what you like to sort and what will be in the UITextField.text

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜