問題は、sqlite DBからデータを取得し、スクロールビュー表示用の配列に配置しようとしているためです。 FMデータベースライブラリを使用してイムは、SQLデータベースに接続するためオブジェクトの数(3)がキーの数と等しくない(8)
次のようにコードがある:だから
NSMutableArray *data = [[NSMutableArray alloc] init];
FMResultSet *result = [[[StorageTank sharedStorageTank] DB]
executeQuery:@"SELECT * FROM table"];
while([result next])
{
NSArray *values = [[NSArray alloc] initWithObjects:
[[NSNumber alloc] initWithInt:[result intForColumn:@"id"]],
[[NSNumber alloc] initWithInt:[result intForColumn:@"count"]],
[[NSNumber alloc] initWithInt:[result intForColumn:@"required"]],
[result stringForColumn:@"image_portrait"],
[result stringForColumn:@"image_landscape"],
[[NSNumber alloc] initWithInt:[result intForColumn:@"end_date"]],
[[NSNumber alloc] initWithInt:[result intForColumn:@"active"]],
[result stringForColumn:@"merchant"], nil];
NSLog(@"%@", values);
NSArray *keys = [[NSArray alloc] initWithObjects: @"id",@"count",@"required",
@"image_portrait",@"image_landscape",
@"end_date",@"active",@"merchant",nil];
NSLog(@"%@", keys);
NSDictionary *row = [[NSDictionary alloc] initWithObjects: values forKeys: keys];
[data addObject: row];
}
NSArray *resultArray = [[NSArray alloc] init];
resultArray = data;
、明らかに私は必ず値はキーがカウントに等しいカウントにするためにテストされたコードから。 ..まだこのエラーが発生しています:
"未知の例外 'NSInvalidArgumentException'の理由でアプリケーションを終了しています:理由: ' - [__ NSPlaceholderDictionary initWithObjects:forKeys:]:オブジェクトの数(3) ) '"
私はできませんなぜ私は私が8値を参照して値の配列をプリントアウトする場合、私の人生のために数えています...私の8つのキーに一致する必要がありますか?彼らは正しいですか?
ご協力いただきありがとうございます。
nil
を返す
[result stringForColumn:@"image_portrait"]
:
おかげで、
image_portrait/image_landscapeはbase64でエンコードされたイメージ文字列であるため、メモリ問題が発生している可能性があります。 –
値のログステートメントは何を表示しますか?あなたはNSNumber値のためのゼロ値を取得している可能性があります? –
コードがふるいのように漏れていることに注意してください。 – bbum