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
// NSLogの第一引数はフォーマット指定子 | |
NSLog(@"%@", [MixiSampleClass getStaticString]); | |
// インスタンス生成 | |
MixiSampleClass* obj = [[MixiSampleClass alloc]init]; | |
(void)[obj initWithName:@"abcdefg" sampleType:SampleTypePiyo]; | |
NSLog(@"%@", obj.name); | |
NSLog(@"%@", obj.name.addSample); |
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
// | |
// MixiSampleClass.h | |
// TrainingObjectiveC | |
// | |
// Created by masai on 2015/06/09. | |
// Copyright (c) 2015年 masai. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
// 列挙型(SampleType enum) | |
typedef NS_ENUM(NSInteger, SampleType){ | |
SampleTypeHoge = 0, | |
SampleTypeHuga, | |
SampleTypePiyo, | |
}; | |
@interface MixiSampleClass : NSObject | |
// プロパティ nonatomic=排他制御しない、strong=オーナーシップをもっている、setter&getterの自動生成 | |
// -setName, -name | |
@property (nonatomic, strong) NSString *name; | |
// インスタンスメソッド - | |
-(id)initWithName:(NSString*) name sampleType:(SampleType) sampleType; | |
// クラス・メソッド + | |
+(NSString*) getStaticString; | |
@end |
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
// | |
// MixiSampleClass.m | |
// TrainingObjectiveC | |
// | |
// Created by masai on 2015/06/09. | |
// Copyright (c) 2015年 masai. All rights reserved. | |
// | |
#import "MixiSampleClass.h" | |
// クラス定数 const | |
static NSString* const constString = @"const"; | |
// クラス変数 static | |
static NSString* staticString = @"static"; | |
// 無名カテゴリ(privateなプロパティの拡張、無名クラス無いで宣言したpropertyやメソッドはprivate扱いになる) | |
@interface MixiSampleClass() | |
@property (nonatomic, assign) BOOL isEnabled; | |
@property (nonatomic, assign) SampleType sampleType; | |
@end | |
@implementation MixiSampleClass | |
// インスタンスメソッド - | |
-(id)initWithName:(NSString*) name sampleType:(SampleType) sampleType | |
{ | |
self = [super init]; | |
if(self){ | |
// access iVar, self.<var>や_<var>でアクセスが可能 | |
_name = name; | |
_isEnabled = YES; | |
_sampleType = sampleType; | |
} | |
return self; | |
} | |
// クラス・メソッド + | |
+(NSString*) getStaticString | |
{ | |
return staticString; | |
} | |
@end |
カテゴリ
あるクラスのメソッド郡を別のモジュールとして宣言する。
NSString+SampleAddition.h
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
// | |
// NSString+SampleAddition.h | |
// TrainingObjectiveC | |
// | |
// Created by masai on 2015/06/10. | |
// Copyright (c) 2015年 masai. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSString (SampleAddition) | |
-(NSString *)addSample; | |
@end |
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
// | |
// NSString+SampleAddition.m | |
// TrainingObjectiveC | |
// | |
// Created by masai on 2015/06/10. | |
// Copyright (c) 2015年 masai. All rights reserved. | |
// | |
#import "NSString+SampleAddition.h" | |
@implementation NSString (SampleAddition) | |
-(NSString *)addSample | |
{ | |
return [NSString stringWithFormat:@"%@sample", self]; | |
} | |
@end |
SlotsCity Casino, Las Vegas - Mapyro
返信削除Find SlotsCity 구리 출장마사지 Casino, 여주 출장안마 Las Vegas, NV, United States, 인천광역 출장샵 ratings, photos, location maps, SlotsCity 영천 출장샵 Casino and Hotel - Overview Slots City Casino and Hotel - Overview 춘천 출장마사지 The Slots City Casino & Hotel - Overview