Last active
December 18, 2015 00:29
-
-
Save katsuhide/5697246 to your computer and use it in GitHub Desktop.
配列(NSArray, NSMutableArray)周り
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// autorelease onで生成 | |
NSMutableArray *Array = [NSMutableArray array]; | |
// autorelease offで生成 | |
NSMutableArray *Array = [[NSMutableArray alloc] init]; | |
NSMutableArray *Array = [[NSMutableArray alloc] initWithObjects: nil]; | |
// 配列の作成 | |
NSArray *ar = [NSArray arrayWithObjects:@"東京", @"名古屋", @"大阪", nil]; | |
// index指定で要素を取得 | |
[array objectAtIndex:0]; | |
// 要素を追加 | |
NSMutableArray *array = [[NSMutableArray alloc]init]; | |
[array addObject:@"name"]; | |
// 指定した場所の要素を削除する | |
[mar removeObjectAtIndex:3]; | |
// 要素数をカウント | |
[array count] | |
// ソート | |
NSArray *array = @[@"The", @"Catcher", @"in", @"the", @"Rye"]; | |
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES]; | |
NSArray *sortedArray = [array sortedArrayUsingDescriptors:@[sortDescriptor]]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment