stringwithstring

Obj-C: [NSString stringWithString:@“string”] vs. @“string”

旧时模样 提交于 2019-11-28 13:17:47
I've seen people do something like [NSString stringWithString:@"some string"] . Why not just do @"some string" ? For an example, look at the facebook-ios-sdk . +[NSString stringWithString:] -- what's the point? is a similar question, but none of the answers address [NSString stringWithString:@"some string"] vs. @"some string" . Actually there is no difference. [NSString stringWithString: str] just does nothing and returns str if str is immutable already. There's no difference other than the extra key strokes needed. In fact, with a constant string as a parameter (or an immutable string) you

Obj-C: [NSString stringWithString:@“string”] vs. @“string”

佐手、 提交于 2019-11-27 07:35:34
问题 I've seen people do something like [NSString stringWithString:@"some string"] . Why not just do @"some string" ? For an example, look at the facebook-ios-sdk. +[NSString stringWithString:] -- what's the point? is a similar question, but none of the answers address [NSString stringWithString:@"some string"] vs. @"some string" . 回答1: Actually there is no difference. [NSString stringWithString: str] just does nothing and returns str if str is immutable already. 回答2: There's no difference other