clarkgrubb / hyperpolyglot

hyperpolyglot.org
Other
473 stars 94 forks source link

Dot Notation Explained Objective C #84

Open 7fe opened 7 years ago

7fe commented 7 years ago

Maybe this isn't needed but https://en.wikipedia.org/wiki/Objective-C does a decent job explaining the dot syntax.

Person *aPerson = [[Person alloc] initWithAge: 53];
aPerson.name = @"Steve"; // NOTE: dot notation, uses synthesized setter,
 // equivalent to [aPerson setName: @"Steve"];
NSLog(@"Access by message (%@), dot notation(%@),
property name(%@) and direct instance variable access (%@)",
 [aPerson name], aPerson.name, [aPerson valueForKey:@"name"], aPerson->name);