Last active
December 11, 2015 08:58
-
-
Save mootoh/4576621 to your computer and use it in GitHub Desktop.
Setting Property is Case Insensitive in Objective-C
This file contains hidden or 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
| #import <Foundation/Foundation.h> | |
| @interface A : NSObject | |
| { | |
| NSString *lowercaseString; | |
| } | |
| @property (strong) NSString *lowercaseString; | |
| @end | |
| @implementation A | |
| @synthesize lowercaseString; | |
| - (id) init | |
| { | |
| self = [super init]; | |
| if (self) { | |
| self.LowercaseString = @"Yay"; // use upper case in setter => ok | |
| NSLog(@"value = %@", self.lowercaseString); // use lower case in getter => ok | |
| // NSLog(@"value = %@", self.LowercaseString); // use upper case in getter => fail | |
| } | |
| return self; | |
| } | |
| @end | |
| int main(int argc, char **argv) | |
| { | |
| A *a = [A new]; // will show "Yay" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment