Last active
August 29, 2015 14:26
-
-
Save ezura/338ca3a8970405257d11 to your computer and use it in GitHub Desktop.
クラスに [], {} を実装する ref: http://qiita.com/ezura/items/dd4ff9b0ae2a1afa3bb3
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
// id obj = custom[@1]; | |
- (id)objectForKeyedSubscript:(id)key; | |
// custom[@1] = @0; | |
- (void)setObject:(id)anObject forKeyedSubscript:(id <NSCopying>)aKey; |
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
- (id)objectForKeyedSubscript:(id)key | |
{ | |
return @"10"; | |
} | |
- (void)setObject:(id)anObject forKeyedSubscript:(id <NSCopying>)aKey | |
{ | |
... | |
} |
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
CustomClass *custom = [CustomClass new]; | |
id arrayObj = custom[1]; | |
custom[0] = @10; | |
id dictObj = custom[@1]; | |
custom[@1] = @0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment