NSString *strMQueryupdate =[NSString stringWithFormat:@"insert into Zpatient_info_image_note values ('%@','%@',NULL,'%@')",@"",autoNumberTextField.text,@""];
NSManagedObjectContext *moc = [self managedObjectContext];
Patient_info_image_note *patientImageData = (Patient_info_image_note *) [NSEntityDescription insertNewObjectForEntityForName:@"Patient_info_image_note" inManagedObjectContext:moc];
patientImageData.autonumber=autoNumberTextField.text;
patientImageData.patient_Info_Note_Image=@"";
patientImageData.noteDate=@"";
patientImageData.noteNumber=NULL;
[moc save:nil];
lastrowid=[[[[patientImageData objectID] URIRepresentation] absoluteString] intValue];
patientImageData=nil;
这段代码有什么不正确的地方?作为第二个选项,我应该创建另一个库,它保存从 0 开始的整数并将其递增 1,然后将其保存到数据库中,以便下次我可以通过数组计数检索最后一个递增的数字。