macOS/iOS API解説

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

目次

replaceObjectsAtIndexes:withObjects:

オブジェクトからインデックスセット分置き換えます
-(void)replaceObjectsAtIndexes:(NSIndexSet *)indexes
               withObjects:(NSArray *)objects

解説

オブジェクトからインデックスセット分置き換えます

返り値

( void )

なし

引数

( NSIndexSet * )indexes
( NSArray * )objects

クラス

NSMutableArray

Instance Methods

使用可能

10.4

参照

-insertObject:atIndex:
-removeObjectAtIndex:
-replaceObjectAtIndex:withObject:

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSMutableArray *muArr = [NSMutableArray arrayWithCapacity:1];
NSArray *arr1 = [NSArray arrayWithObjects:	@"111",@"222",@"333",@"444",@"555",
											@"666",@"777",@"888",@"999",@"000",nil];
NSArray *arr2 = [NSArray arrayWithObjects:	@"aaa",@"bbb",@"ccc",@"ddd",@"eee",
											@"fff",@"ggg",@"hhh",@"iii",@"jjj",nil];
										
NSArray *arr3 = [NSArray arrayWithObjects:	@"111",@"222",@"333",@"444",@"555",nil];
[muArr setArray:arr1];

NSLog([muArr description]);

NSIndexSet *aSet1 = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,10)];
[muArr replaceObjectsAtIndexes: aSet1 withObjects: arr2 ];

NSLog([muArr description]);

NSIndexSet *aSet2 = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,5)];
[muArr replaceObjectsAtIndexes: aSet2 withObjects: arr3 ];

NSLog([muArr description]);
}

@end