Created
November 2, 2013 20:58
-
-
Save takuya/7283465 to your computer and use it in GitHub Desktop.
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
// | |
// main.m | |
// MyTestCmd | |
// | |
// Created by takuya on 2013/11/01. | |
// Copyright (c) 2013年 takuya. All rights reserved. | |
// | |
//メモ 略語について | |
// CF : Cocoa Foundation | |
// NS : Next Step | |
// nib : NeXT Interface Builder | |
// xib : OS X Interface Builder(かな?) | |
#include "Human.h" | |
@interface Animal : NSObject | |
@property NSString *name; | |
@property NSString *voice; | |
-(void) bark; | |
-(NSString *) info; | |
-(id) initWithName:(NSString *)n; | |
-(id) initWithNameAndVoice: (NSString *)n :(NSString *)v; | |
@end | |
@implementation Animal | |
- (void) bark{ | |
NSString *a = self.voice; | |
const char *cp =[a UTF8String]; | |
printf("「%s」\n", cp); | |
} | |
- (NSString *) info{ | |
return [NSString stringWithFormat:@"%@: %@と鳴きます\n", self.name, self.voice]; | |
} | |
- (id)init { | |
self = [super init]; | |
self.name = @"未確認生物"; | |
self.voice = @"□□□□□□"; | |
return self; | |
} | |
- (id)initWithName: (NSString *)n { | |
self = [super init]; | |
self.name = n; | |
return self; | |
} | |
- (id)initWithNameAndVoice: (NSString *)n :(NSString *)v { | |
self = [super init]; | |
self.name = n; | |
self.voice = v; | |
return self; | |
} | |
@end | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
NSMutableArray *animals ; | |
animals = [[NSMutableArray alloc]init]; | |
NSDictionary *dict = @{ | |
@"ドッグ": @"わんわん", | |
@"キャット": @"にゃーん", | |
@"ピジョン": @"くるっぽー", | |
@"ピッグ": @"ぶひぶひー", | |
}; | |
for( id key in dict){ | |
Animal *anAnimal = [[Animal alloc]initWithNameAndVoice:(NSString *)key :dict[(NSString *)key] ]; | |
[animals addObject:anAnimal]; | |
} | |
for ( id e in animals ) { | |
printf("%s",[[e info ] UTF8String] ); | |
[e test]; | |
} | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment