exchangeObjectAtIndex:withObjectAtIndex:
重複?変更可能な配列の指定番号オブジェクトと別の指定番号オブジェクトを入れ替えます
-(void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2
解説
変更可能な配列の指定した番号のオブジェクト(idx1)ともう一つの指定した番号のオブジェクト(idx2)を入れ替えます。
返り値
( void )
なし
引数
( NSUInteger )idx1
( unsigned )idx1
入れ替えるオブジェクト1の番号
( NSUInteger )idx2
( unsigned )idx2
入れ替えるオブジェクト2の番号
フレームワーク
Foundation
クラス
NSMutableArray
Instance Methods
使用可能
10.2
参照
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSArray *arr1 = [NSArray arrayWithObjects:@"a", @"b",@"a", @"b",@"a", @"b",@"a", nil]; NSMutableArray *muArr = [NSMutableArray arrayWithCapacity:1]; [muArr addObjectsFromArray:arr1]; NSLog([muArr description]); [muArr exchangeObjectAtIndex:1 withObjectAtIndex:2]; NSLog([muArr description]); } @end