We can create an NSNumber like this
NSNumber *number = [NSNumber numberWithFloat:4.5];
//or
NSNumber *number = @(4.5);
//or
NSNumber *number = @4.5;
I know we can convert to an NSString with the following statement
NSString *string = @("stuff"); //equivalent of [NSString stringWithUTF8String]
However, can we create an NSString like this?
NSString *string = @(@"Name is:%@",name); //equivalent of [NSString stringWithFormat]
This is just off the top of my head. I do not think there's any syntactic sugar for this.
Though, I believe you could achieve what you are looking for like this:
Put this in your .pch file
#define format(s, ...)
[NSString stringWithFormat:s, ##__VA_ARGS__]
And call it :
NSString *s = format(@"%@, %@", @"a", @"b");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With