I'm a newcomer to the iPhone world. (Previously, I've developed for android.)
I've got this code in one of my Android apps:
String body = "<Item type='Customer' id= '"+id+"' action='delete'/>";
What's the same in Objective-C?
I'm a newcomer to the iPhone world. (Previously, I've developed for android.)
I've got this code in one of my Android apps:
String body = "<Item type='Customer' id= '"+id+"' action='delete'/>";
What's the same in Objective-C?
As Henrik says, it's:
NSInteger id = 5;
NSString* body = [NSString stringWithFormat:@"<Item type='Customer' id= '%d' action='delete'/>", i];
(A purist may argue with this, though.)
But really the answer is to read through "Learning Objective-C: A Primer." It's not terribly long and shows you pretty much everything you need to know about the language.
You can use -[NSString stringWithFormat:]
:
NSString *body = [NSString stringWithFormat:@"<Item type='Customer' id='%@' action='delete'/>", idNum];
Assuming the ID is stored in the variable idNum
. (id
is actually a type in Objective-C, so you don't want to use that as a variable name.)
String body = "<Item type='Customer' id= '"+id+"' action='delete'/>";
NSString* id = @"foo";
NSString* body
= [NSString stringWithFormat:@"<Item type='Customer' id='%@' action='delete'/>", id ];