I’ve started learning objective-C for my iPhone SDK programming project and was wondering how to concatenate strings and integers, … I saw a number of posts on the web about how verbose Objective-C is compared to C#. No mention was made that C# arrived 20 years after Objective-C and it was a poorer version of Java. Anyhow, want to concatenate a bunch of primitive types as a string? Here is what you do (recall your sprintf syntax)
[NSString stringWithFormat: @"Hello Aqua %@ %d", @"cue ", 1];
For string concatenation, Objective-C is almost as concise as Perl -)
August 28, 2009 at 5:52 am |
NSString *ns, *val;
ns = “welcome”;
val = “world”;
while i using “[NSString stringWithFormat:"%@%@", ns,val]” this command i am getting bellow error:
An unhandled win32 exception occurred in “TestProject.exe”
plz anybody help me, to solve this problem
i am new for objective-c/cocoa
November 25, 2009 at 6:28 pm |
ns = @”welcome”;
val = @”world”;
To use the %@ formatter the object has to be derived from NSObject. Trying to assign a C string to an NSString will tend strongly to crash. So you use the @ prefix to make an NSString literal. Or you can just use char* strings and use %s in the format. It’s probably more efficient.
September 20, 2011 at 4:30 pm |
can I ask how can I concatenate string values of buttons??
March 20, 2012 at 6:29 pm |
programmatore php roma…
[...]Objective-C & string concatenation « n o t e 1 9 . c o m[...]…