Pillblast
Pillblast

Reputation: 1221

How do I write " inside a string? Objective C

How can I write a " inside an Objective-C string?

For example I have the

NSString *sql= @"select * from test where name="name"";

Upvotes: 0

Views: 876

Answers (3)

Najeebullah Shah
Najeebullah Shah

Reputation: 3709

say you have string like @"abc"def"123"; do it like @"abc\"def\"123";

Upvotes: 0

Jason Coco
Jason Coco

Reputation: 78393

NSString* name = @"Jason";
NSString* selectStatement = [NSString stringWithFormat:@"select * from foo where name = \"%@\"", name];

Upvotes: 0

Lindydancer
Lindydancer

Reputation: 26134

Use \". In your case it would be:

NSString *sql= @"select * from test where name=\"name\""

Upvotes: 4

Related Questions