1

Sqlite データベースを使用しています。

私のデータベースでは

いいね、請求書、名前、日付をいくつか提出しました

私の Invoiceno データ型は INTEGER です。

Selectクエリでは、このような出力が得られました。

 Query:(
    {
     InvoiceNo = 1;
     Name : ABC
     Date = "2012-04-16 00:00:00";

    }
  )

しかし、Invoice no to string を取得しようとすると、Diff が指定されます。価値。

請求書を配列から文字列に取得するためのコード:

  NSString *str = [NSString stringWithFormat:@"%i",[[Query objectAtIndex:indexPath.row] valueForKey:@"InvoiceNo"]];
    NSLog(@"str:%@",str);

ここで、請求書番号は 1 で、値は「2387056」です。

助けてください.どうすればこの問題を解決できますか?

4

2 に答える 2

2
NSString *str = [NSString stringWithFormat:@"%i",[[Query objectAtIndex:indexPath.row] valueForKey:@"InvoiceNo"]];
    NSLog(@"str:%@",str);
you have to replace above lines with below lines

NSString *str = [NSString stringWithFormat:@"%i",[[[Query objectAtIndex:indexPath.row] valueForKey:@"InvoiceNo"] intValue]];
    NSLog(@"str:%@",str);
于 2012-04-16T13:07:40.130 に答える
1

NSString を int に変換する

NSString *values = @"1";

int yourValue = [values intValue];

NSLog(@"Int Value : %d",yourValue);
于 2012-04-16T13:08:31.773 に答える