I am just curious if I am doing this right.
NSString *fileContents;
NSError *fileError = nil;
fileContents = [[NSString stringWithContentsOfFile:fileOnDisk
encoding:NSMacOSRomanStringEncoding
error:&fileError] retain];
if(fileError != nil) {
NSLog(@"Error : %@", [fileError localizedDescription]);
}
// Other Code ...
[fileContents release];
.
EDIT (to reflect bbums comments)
.
NSString *fileOnDisk = @"/Users/Gary/Documents/Xcode/RnD/Maya.MEL";
NSError *fileError; // Should this be *fileError = nil;
NSString *fileContents;
int status = 0;
fileContents = [[NSString stringWithContentsOfFile:fileOnDisk
encoding:NSMacOSRomanStringEncoding
error:&fileError] retain];
if(fileContents == nil) {
NSLog(@"FileError: %@", [fileError localizedDescription]);
status = 1;
} else {
NSLog(@"Success : %@", fileContents);
}
// Clean up
[fileContents release];
[pool drain];
return status;
gary