Bad receiver type "int" error when using the book's code


I am getting a “bad receiver type “int”” error on this line of code from the challenge section of the book:

[quote]NSString *nameString = [NSString stingWithContentsOfFile:@"/usr/share/dict/propernames"

It specifically is pointing to this:

I keep checking for mistakes, but I can’t seem to get rid of the error. Can anyone give me some help?


That’s because you are not checking carefully; as a consequence, you are being [color=#FF0000]stung[/color].

Compare this:

NSString *nameString = [NSString stringWithContentsOfFile:@"/usr/share/dict/propernames"


Thanks. But even with the fix, I am still getting the same error.


If ibex10’s code didn’t fix it, then the error is likely somewhere else, despite the compiler thinking it’s here.

Can you paste a longer code segment surrounding the snippet you’ve provided?


This is the whole thing:


There is a syntax error: the square bracket [ before NSUTF8StringEncoding token. Delete the square bracket and compile again.


I am having the same problem, and cannot locate any syntax error.

NSString *nameString = [NSString stringWithContentsOfFile:@"/usr/share/dict/propernames" usedEncoding:NSUTF8StringEncoding error:NULL];

I am still getting an error: "Incompatible integer to pointer conversion sending “int”.

Can anyone help?