Make the @ prefix on string object literals optional
| Originator: | bigzaphod | ||
| Number: | rdar://11945420 | Date Originated: | July 24, 2012 |
| Status: | Closed (Nope) | Resolved: | April 8, 2013 |
| Product: | Developer Tools | Product Version: | |
| Classification: | Reproducible: |
I wish we could optionally eliminate the @ prefix for Objective-C string literals. It seems like in most cases the compiler should be able to infer when an object is being expected and do it for me automatically. For example: NSString *str = @"blah"; The (NSString *) is right there! It should know! I should be able to say: NSString *str = "blah"; Likewise, for the new dictionary indexing accessors, they only accept objects so it should be quite reasonable to convert what looks like a C string into an NSString automatically so the code looks better: NSDictionary *myDict = [NSDictionary new]; myDict["key"] = value; rather than this: myDict[@"key"] = value; which, IMO, looks ugly.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
There are several cases where it doesn't work without the @. How would you make a C-String?