使用数组存储在sqlite表中添加数据仅限于最后输入的记录

时间:2013-04-18 04:08:20

标签: iphone ios ipad sqlite nsmutablearray

我在sqlite表中插入数据,然后在表View中显示该数据。问题是,当我插入ABC然后它显示在表ABC,但当我再次插入XYZ然后它只显示XYZ而不是ABC和XYZ。这是选择我插入的数据的方法:

   NSMutableArray *tempArray3 = [[NSMutableArray alloc] init];
   self.libraryArray = tempArray3;
   [tempArray3 release];
   [Coffee getInitialDataToDisplayL:[self getDBPath]];

添加数据方法:

- (void) addCoffee:(Coffee *)coffeeObj {
    //Add it to the database.
    [coffeeObj addCoffee];
    int countone=[libraryArray count];
    NSLog(@"count Before Adding is %d",countone);

    //Add it to the coffee array.
    [libraryArray addObject:coffeeObj];
    int count=[libraryArray count];
    NSLog(@"count After Adding is %d",count);
    NSLog(@"Successfully added");
}

0 个答案:

没有答案