NSSTring question


#1

So, on chapter 32, there is a program that I typed in that compiled fine, but then got a runtime error.

It got a EXC_BAD_ACCESS (code=1, address=0x10) on this line:

[newString replaceOccurrencesOfString:s

I kept desk-checking the code and could not find the typo, so I retyped the entire program and it worked, so then I copied them both into text wrangler and had it compare them and found that I had made a mistake on a NSSTring literal.

Instead of this:

// Create a list of characters that we'll remove from the string NSArray *vowels = [NSArray arrayWithObjects: @"a", @"e", @"i", @"o", @"u", nil];
I had this:

// Create a list of characters that we'll remove from the string NSArray *vowels = [NSArray arrayWithObjects: @"a", @"e", "@i", @"o", @"u", nil];

Hint: look at the literal for “i”.

So, I know in a normal C program the /n at the end is for a new line. What has not been explained up to this point is why NSSTrings start with @ in front of the quote.

What I REALLY don’t understand is why this is not a compile time error.

Anyone interested in expanding on this?

Thanks.
-Todd