我想获取特定城市的记录但是当我调试此代码时,虽然声明不起作用,但它总是在循环之外。
-(NSMutableArray*) getAddressCellLatLong :(NSString *)clinicCity
{
NSMutableArray *dataArray = [[NSMutableArray alloc]init];
NSString * sqlStr=[NSString stringWithFormat:@"select address,phone,mobile,type,latitude,longitude from getclinic where city ='%@'",clinicCity];
sqlite3_stmt *ReturnStatement = (sqlite3_stmt *) [self getStatement: sqlStr];
while(sqlite3_step(ReturnStatement) == SQLITE_ROW)
{
@try
{
ClinicDC* clinic = [[ClinicDC alloc]init];
NSString *clinicID = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 0)];
NSString *address = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 1)];
NSString *phone = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 2)];
NSString *mobile = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 3)];
NSString *type = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 4)];
NSString *city = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 5)];
NSString *country = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 6)];
NSString *latitude = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 7)];
NSString *longitude = [NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement, 8)];
clinic.clinicID = [clinicID intValue];
clinic.cCity = city;
clinic.cCountry = country;
clinic.cType = type;
clinic.cAddress = address;
clinic.cPhone = phone;
clinic.cMobile = mobile;
clinic.cLongitude = longitude;
clinic.cLatitude = latitude;
[dataArray addObject:clinic];
}
@catch (NSException *ept) {
NSLog(@"Exception in %s, Reason: %@", __PRETTY_FUNCTION__, [ept reason]);
}
}
return dataArray;
}