Created
May 28, 2014 20:23
-
-
Save takkyun/5d7fc1a26b80f7fdfe46 to your computer and use it in GitHub Desktop.
カテゴリーでインスタンス変数 ref: http://qiita.com/takkyun@github/items/b6de22f5a4f494f534da
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
@interface MyClass (CategoryName) | |
// 追加したいメソッド | |
@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
@interface MyClass (CategoryName) | |
{ | |
id _newMember; // <= これは無理 | |
} | |
- (void)newMethod; | |
@end | |
@interface MyClass () | |
{ | |
id _newMember; // <= これは OK | |
} | |
@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
@interface MyClass (CategoryName) | |
{ | |
id _newMember; // <= これは無理 | |
} | |
- (void)newMethod1; | |
- (void)newMethod2; | |
@end | |
@interface MyClass () | |
{ | |
id _newMember; // <= これは OK | |
} | |
@end | |
@implementation MyClass (CategoryName) | |
- (void)newMethod1 | |
{ | |
_newMember = ...; // なんか代入 | |
} | |
- (void)newMethod2 | |
{ | |
NSLog(@"%@",_newMember); // newMethod1 に先にアクセスしていれば、その内容がちゃんと見れる | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment