Hi guys, I'm reading this book called "Programming Objective-C 2.0" by Stephen G. Kochan. In chapter 20, he put the following snippet:
Code:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSDictionary *glossary =[NSDictionary dictionaryWithObjectsAndKeys:
@"Class declared so other classes can be inherited from it.",
@"abstract class",
@"To implement all the methods defined in a protocol.",
@"adopt",
@"Storing an object for later use.",
@"archiving",
nil
];
if([glossary writeToFile:@"glossary" atomically:YES encoding:NSUTF8Encoding error:nil] == NO)
{
NSLog(@"Save to file failed.");
}
[pool drain];
return 0;
}
But when I try to compile it, it says NSUTF8Encoding is undeclared. I have copied the example twice with no luck. Can someone tell me a good fix for this issue? I don't want to skip the chapter because it's quite important.
EDIT: It also says glossary may not respond to the writeToFile:atomically:encoding:error: method. WTF.