Quick question about nil. I have this code to check for a file and if it exists it returns it. In the IF statement I return the file if it exists. But I am getting a warning if I do not have a return at the end of this Method "Control may reach end of non-void function"
I thought I would add a "return nil" if it can not locate the file. Is this the best way of doing it to get rid of the warning error?
Code:
-(NSDictionary *)readInGearDict{
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:[self filePath:@"masterGearList.plist"]]) {
NSDictionary *gearDict = [[NSDictionary alloc] initWithContentsOfFile:[self filePath:@"masterGearList.plist"]];
[COLOR="Red"] return gearDict;[/COLOR]
}
[COLOR="Red"]return nil;[/COLOR]
}
I thought I would add a "return nil" if it can not locate the file. Is this the best way of doing it to get rid of the warning error?