macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

initWithKey:ascending:selector:

キー、昇順、セレクタでソートデスクリプタを初期化して返します
-(id)initWithKey:(NSString *)key:
             ascending:(BOOL)ascending:
             selector:(SEL)selector :

解説

キー、昇順、セレクタでソートデスクリプタを初期化して返します。

返り値

( id )

オブジェクト()

引数

( NSString * )key
( BOOL )ascending
( SEL )selector 

クラス

NSSortDescriptor

Instance Methods

使用可能

10.3

参照

-initWithKey:ascending:

例文

#import "MyObject.h"

@implementation MyObject
//myOutlet テーブルビュー
//tColumn1 テーブルコラム
//tColumn2 テーブルコラム
- (IBAction)myAction:(id)sender
{
NSSortDescriptor *descriptor=[[[NSSortDescriptor alloc] initWithKey:@"key1" 
                                    ascending:NO selector:NSSelectorFromString(@"compare:")] autorelease];
                                                    

NSSortDescriptor *revDescriptor = [descriptor reversedSortDescriptor];
NSLog([descriptor description]);
NSLog([revDescriptor description]);
}

@end