检查是否有来自数据库的内容时,我遇到了问题:
码:
hourPrograma: @"12:00"; NSArray *hourLinha = [hourProgram componentsSeparatedByString:@":"]; NSArray * test = [notificationDAO selectHourMin:[hourLinha[0] intValue]:[hourLinha[1] intValue]]; if (!test[0]) { NSLog(@"ok!!!"); } else { NSLog(@"empty!!!"); }
我的查询:
-(NSArray *) selectHourMin:(NSInteger *) hour: (NSInteger *) min { query = [NSString stringWithFormat:@"SELECT hour, min FROM notification WHERE %i = hour AND %i = min", hour, min]; NSArray * resp = [self loadDataFromDB:query]; return resp; }
当我检查它是否为空或是否返回某些内容时,会出现错误.
用.替换test [0]
test.count > 0