Skip to content

Instantly share code, notes, and snippets.

@mootoh
Last active December 11, 2015 08:58
Show Gist options
  • Select an option

  • Save mootoh/4576621 to your computer and use it in GitHub Desktop.

Select an option

Save mootoh/4576621 to your computer and use it in GitHub Desktop.
Setting Property is Case Insensitive in Objective-C
#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