In my app when i insert data by clicking on add button data will be inserted into database and table.record will be inserted perfectly but when i add that data into table it duplicates the database data..here is the code:
NSString *insertData=[NSString stringWithFormat:@"insert into tbl_Bills(Amount,Note,Due_On) values ('%f','%@','%@')",addAmountInDouble,val,due];
[database executeQuery:insertData];
NSLog(@"inert query: %@",insertData);
NSLog(@"value inserted");
NSString *countQuery = [NSString stringWithFormat:@"Select Bill_Id,Entry_Date,Amount,Note,Due_On from tbl_Bills"];
NSArray *countArray1 = [database executeQuery:countQuery];
NSLog(@"Query:%@",countArray1);
[BillTableArray addObjectsFromArray:countArray1];
NSLog(@"Count array %@",countQuery);
NSLog(@"table array:%@",BillTableArray);
[database close];
[table reloadData];
count array is fine but table array duplicates the value..i also initialize table array in viewDidLoad() method.
first of all you need to clear your table array before adding new objects :
[BillTableArray removeAllObjects];after add new updated objects :