Created
July 22, 2012 01:18
-
-
Save inonb/3157855 to your computer and use it in GitHub Desktop.
[iOS] 配列と辞書
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
// 配列を作る | |
NSArray *iphones = [NSArray arrayWithObjects:@"iPhone3G", @"iPhone3GS", @"iPhone4" nil]; | |
// 配列から要素を取り出す | |
NSString *item2nd = [iphones objectAtIndex:2]; | |
NSLog(item2nd); // ログに iPhone4 | |
// 辞書を作る | |
NSDictionary *macbookair = [NSDictionary dictionaryWithObjectsAndKeys: | |
@"1.7GHz", @"cpu", | |
@"4G", @"memory", | |
@"11.6inch", @"display", | |
nil]; | |
// 辞書から要素を取り出す | |
NSString *cpu = [iphones objectAtIndex:0]; | |
NSLog(cpu); // ログに 1.7GHZ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment