我正在开发一个项目,其中我有一个数据库sqlite 3,其中我有3个文本列,我正在获取值并将它们显示在视图中; text6 fields.but在我的代码中有一个条件,用户可以填充任何一个文本字段三和两个可以是空白但当我提取值时,两个文本字段显示(null)而不是空值我如何解决这个问题问题,以便在获取数据后,它将显示空白而不是空 这是我插入数据的代码
- (void)saveData
{
if ((txtfield.text.length==0)||(txtfield1.text.length==0)||(txtfield2.text.length==0)||(txtfield3.text.length==0)||(txtfield4.text.length==0))
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"fields can't be blank"
message:@"fill the fields"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
else{
NSString* gratitude2 = [NSString stringWithFormat:@"%@",txtfield3.text];
NSString* gratitude1 = [NSString stringWithFormat:@"%@",txtfield4.text];
NSString* title = txtfield.text;
NSString* date = txtfield1.text;
NSString* gratitude = [NSString stringWithFormat:@"%@",txtfield2.text];
[dbSingleton() createEditableCopyOfDatabaseIfNeeded];
[dbSingleton() insertdata:gratitude2 withgratitude1:gratitude1 title:title date:date gratitude:gratitude picture:imageDt audio:self.retrieveData];
}
这里是在iphone上的视图上显示它
-(void)gototree:(UIButton *)sender
{
int tag1=sender.tag;
[dbSingleton() createEditableCopyOfDatabaseIfNeeded];
NSMutableArray * array=[[NSMutableArray alloc]init];
array =[dbSingleton() getalldata:tag1];
NSString *gratitude22=[[array objectAtIndex:0]valueForKey:@"gratitude2"];
NSString *gratitude11=[[array objectAtIndex:0]valueForKey:@"gratitude1"];
NSString *title11 = [[array objectAtIndex:0]valueForKey:@"title"];
NSString *date11=[[array objectAtIndex:0]valueForKey:@"Date"];
NSString *gratitude=[[array objectAtIndex:0]valueForKey:@"gratitude"];
txtfield2=[[UITextField alloc]initWithFrame:CGRectMake(28, 164, 200,20)];
txtfield2.backgroundColor=[UIColor clearColor];
txtfield2.font=[UIFont fontWithName:@"Helvetica-Bold" size:13.0];
[self.view addSubview:txtfield2];
[txtfield2 setEnabled:NO];
txtfield2.text=gratitude;
txtfield3=[[UITextField alloc]initWithFrame:CGRectMake(28, 183, 200,20)];
txtfield3.backgroundColor=[UIColor clearColor];
txtfield3.font=[UIFont fontWithName:@"Helvetica-Bold" size:13.0];
[self.view addSubview:txtfield3];
[txtfield3 setEnabled:NO];
txtfield3.text=gratitude22;
txtfield4=[[UITextField alloc]initWithFrame:CGRectMake(28, 204, 200,20)];
txtfield4.backgroundColor=[UIColor clearColor];
txtfield4.font=[UIFont fontWithName:@"Helvetica-Bold" size:13.0];
[self.view addSubview:txtfield4];
[txtfield4 setEnabled:NO];
txtfield4.text=gratitude11;
}