-1

this is killing me but is there any simple way to have objective-c code inside my UITextView if I'm creating it with code and not in interface builder?

 basicSoundTextView.text = @"NSString *name = [[NSString alloc] initWithFormat:@"NameOfSoundFile"];";

Which gives me errors I'm assuming because I'm using parentheses within the designated parentheses for the text of my textView. I can't tell you exactly what error it gives because there is nothing wrong with the code I'm attempting to insert... however it is telling me it's improperly formatted which I know it isn't it works flawlessly but it doesn't matter because I'm just trying to display it. I don't know how something so simple became so frustrating so quickly so thank you very much in advance!

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281

1 Answers1

2

You have a double quotation problem ...

Rewrite like this and I believe it should work:

basicSoundTextView.text = @"NSString *name = [[NSString alloc] initWithFormat:@\"NameOfSoundFile\"];";
Dair
  • 15,910
  • 9
  • 62
  • 107
  • @MDT: The "\" wont appear when it is displayed. It is just there to indicate that you are not ending the string there. – Dair May 21 '11 at 00:22