I have the current code:
if ([fetchedObjects count] == 0){
Timetable *info = nil;
} else {
Timetable *info = [fetchedObjects objectAtIndex:0];
}
// Return Data
return info;
Inside a method in one of my classes. This code should run but xcode gives me the errors:
Use of undeclared identifier 'info'
for the return info and
Unused variable 'info'
for the Timetable *info parts.
I have no clue why this is happening and the app does crash if I try to run it due to this. If i were to set the timtable without the if statement like this, it would work:
Timetable *info = [fetchedObjects objectAtIndex:0];
Can someone tell me what i’m doing wrong? Thanks.
You are declaring
infovariables in two different places, inside theiforelse.infois not visible outside of the block. (This is basic C language stuff.)This reads a little better: