I want to copy items from an array that are not 0 or @"" (depending if NSNumber or NSString). The following code, however, does not work. What am I doing wrong?
for (int i=0; i < [logbookItems count]; i++) {
NSLog(@"%@, %@, %@", [[[logbookItems objectAtIndex:i] objectAtIndex:1] class], [[logbookItems objectAtIndex:i] objectAtIndex:0], [[logbookItems objectAtIndex:i] objectAtIndex:1]);
if ((([[[logbookItems objectAtIndex:i] objectAtIndex:1] isKindOfClass:[NSNumber class]]) && ([[logbookItems objectAtIndex: i] objectAtIndex: 1] > 0))
|| (([[[logbookItems objectAtIndex:i] objectAtIndex:1] isKindOfClass:[NSString class]]) && ([[logbookItems objectAtIndex: i] objectAtIndex: 1] != @""))) {
[visibleLogbookItems addObject: [logbookItems objectAtIndex: i]];
}
}
It produces the following log:
2010-10-01 12:46:48.301 PilotsMate[1750:207] (
21,
10,
1985,
"Test AC Mark",
"",
"",
"",
"Test Mission",
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
)
2010-10-01 12:46:52.996 PilotsMate[1750:207] NSCFNumber, Day: , 21
2010-10-01 12:46:52.997 PilotsMate[1750:207] NSCFNumber, Month: , 10
2010-10-01 12:46:52.997 PilotsMate[1750:207] NSCFNumber, Year: , 1985
2010-10-01 12:46:52.998 PilotsMate[1750:207] NSCFString, Aircraft Type: , Test AC Mark
2010-10-01 12:46:52.998 PilotsMate[1750:207] NSCFString, Airframe Number: ,
2010-10-01 12:46:52.999 PilotsMate[1750:207] NSCFString, Pilot: ,
2010-10-01 12:46:53.000 PilotsMate[1750:207] NSCFString, Crew: ,
2010-10-01 12:46:53.000 PilotsMate[1750:207] NSCFString, Mission: , Test Mission
2010-10-01 12:46:53.001 PilotsMate[1750:207] NSCFNumber, Pilot Hours (Day): , 0
2010-10-01 12:46:53.002 PilotsMate[1750:207] NSCFNumber, Crew Hours (Day): , 0
2010-10-01 12:46:53.002 PilotsMate[1750:207] NSCFNumber, Pilot Hours (Night): , 0
2010-10-01 12:46:53.003 PilotsMate[1750:207] NSCFNumber, Crew Hours (Night): , 0
2010-10-01 12:46:53.004 PilotsMate[1750:207] NSCFNumber, Simulator Hours: , 0
2010-10-01 12:46:53.005 PilotsMate[1750:207] NSCFNumber, IF Simulated: , 0
2010-10-01 12:46:53.006 PilotsMate[1750:207] NSCFNumber, IF Actual: , 0
2010-10-01 12:46:53.006 PilotsMate[1750:207] NSCFNumber, No. of SRA: , 0
2010-10-01 12:46:53.008 PilotsMate[1750:207] NSCFNumber, No. of PAR: , 0
2010-10-01 12:46:53.009 PilotsMate[1750:207] NSCFNumber, No. of ILS: , 0
2010-10-01 12:46:53.020 PilotsMate[1750:207] NSCFNumber, No. of GPS: , 0
2010-10-01 12:46:53.023 PilotsMate[1750:207] NSCFNumber, No. of SCA: , 0
2010-10-01 12:46:53.024 PilotsMate[1750:207] NSCFNumber, No. of ELVA: , 0
2010-10-01 12:46:53.025 PilotsMate[1750:207] NSCFNumber, DL (Day): , 0
2010-10-01 12:46:53.028 PilotsMate[1750:207] NSCFNumber, DL (Night - Conventional): , 0
2010-10-01 12:46:53.030 PilotsMate[1750:207] NSCFNumber, DL (Night - NVG): , 0
2010-10-01 12:46:53.030 PilotsMate[1750:207] NSCFNumber, GFP: , 0
2010-10-01 12:46:53.031 PilotsMate[1750:207] NSCFNumber, IFP: , 0
2010-10-01 12:46:53.032 PilotsMate[1750:207] NSCFNumber, NVG: , 0
2010-10-01 12:46:53.032 PilotsMate[1750:207] NSCFNumber, RNFA: , 0
2010-10-01 12:46:53.033 PilotsMate[1750:207] NSCFNumber, Instructional Hours (Day): , 0
2010-10-01 12:46:53.033 PilotsMate[1750:207] NSCFNumber, Instructional Hours (Night): , 0