1

i want to initialize NSString is as "hai" with double qoutes..is it possible? any help please? but NSString *str = @"hai"; i want to convert it as "hai" without direct initialization?any help pls?

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178

2 Answers2

5

If you want to convert an existing string please use this:

NSString *newString = [NSString stringWithFormat:@"\"%@\"",str];
diederikh
  • 25,221
  • 5
  • 36
  • 49
2

NSString* foo = @"\"hai\"";

psychotik
  • 38,153
  • 34
  • 100
  • 135
  • but NSString *str = @"hai"; i want to convert it as "hai" without direct initialization?any help pls? –  Jun 25 '10 at 06:31
  • 1
    psychotik gave you the correct answer. what do you mean without direct initialization??? you have to use \" where ever you want " to be a part of your string, even when theres no direct initialization (whatever you mean by that).. – Swapnil Luktuke Jun 25 '10 at 06:51