orta / ARAnalytics

Simplify your iOS/Mac analytics
MIT License
1.83k stars 217 forks source link

Changed pointers to const immutable strings to const pointers to immutable strings #202

Closed diogot closed 9 years ago

orta commented 9 years ago

Any reasoning for this?

orta commented 9 years ago

Ah, re-reading the title so the const is referring to the pointer here, and not the NSString?

diogot commented 9 years ago

The const is a bit tricky, it applies to the left side type unless it is not present, in this case applies to the right. Like const int x = 2 is the same as int const x = 2. The thing gets trickier when you get pointers, if you have a pointer to an object like NSString *x = @"a" and want to make the object const you can do const NSString *x = @"a" or NSString const *x = @"a" but if you want a constant pointer to a constant object const NSString * const x = @"a" or NSString const * const x = @"a" but since NSString is immutable (and I'm not sure if it was a NSMutableString the former case makes it constant) you can drop the first const:

NSString * const x = @"a";

You can take a look at Wikipedia article about const for more details.

orta commented 9 years ago

Great, thanks @diogot :dancers:

diogot commented 9 years ago

;-)