0

多くの検索の後、さまざまな解決策を見つけましたが、私の場合は何も機能しません。NSDictionary でデータをバインドすると、このエラーが発生します。クラッシュ ログは次のとおりです。

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil.  Or, did you forget to nil-terminate your parameter list?'
*** First throw call stack:

コード:

 while(sqlite3_step(select_statement) == SQLITE_ROW)

    {

//            const char* recipeID = (const char*)sqlite3_column_text(select_statement, 1);
//            const char* recipename = (const char*)sqlite3_column_text(select_statement, 0);
//            const char* recipepicname = (const char*)sqlite3_column_text(select_statement, 3);
//            const char* chapterid = (const char*)sqlite3_column_text(select_statement, 4);
//            const char* recipedesc = (const char*)sqlite3_column_text(select_statement, 2);
//            
//            
//             srtRecipestepId = recipeID == NULL ? nil : [[NSString alloc]initWithUTF8String:recipeID];
//             strRecipeName = recipename == NULL ? nil : [[NSString alloc]initWithUTF8String:recipename];
//             NSString *recipePicName = recipepicname == NULL ? nil : [[NSString alloc]initWithUTF8String:recipepicname];
//             strRecipeIntro = recipedesc == NULL ? nil : [[NSString alloc]initWithUTF8String:recipedesc];
//             NSString *strchapterId = chapterid == NULL ? nil : [[NSString alloc]initWithUTF8String:chapterid];

            srtRecipestepId=[NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 1)];
            strRecipeName=[NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 0)];
           // RecipestepPics = [[NSData alloc] initWithBytes:sqlite3_column_blob(select_statement, 3) length:sqlite3_column_bytes(select_statement, 3)];
           NSString *recipePicName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 3)];
            strRecipeIntro = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 2)];
            NSString *strchapterId = [NSString stringWithUTF8String:(char *)sqlite3_column_text(select_statement, 4)];

            [arrreturnRecipefinder addObject:[NSDictionary dictionaryWithObjectsAndKeys:srtRecipestepId,@"RecipestepId",strRecipeName,@"RecipeName",recipePicName,@"RecipestepPics",strRecipeIntro,@"RecipeIntro",strchapterId,@"RecipeChapterId"]];


        }
4

2 に答える 2

1

エラーメッセージから:

... または、パラメーター リストを nil で終了するのを忘れましたか?

はい、そうでした!そのはず

[NSDictionary dictionaryWithObjectsAndKeys:srtRecipestepId, @"RecipestepId",
                    strRecipeName, @"RecipeName",
                    recipePicName, @"RecipestepPics",
                   strRecipeIntro, @"RecipeIntro",
                     strchapterId, @"RecipeChapterId",
                     nil]   // <-- nil-termination of variable argument list
于 2013-08-22T06:50:11.517 に答える
0

nil辞書の末尾にパラメーターを追加しませんでしnilた。「引数の末尾」リストをマークするための「センチネル」として使用されるためです。

 [arrreturnRecipefinder addObject:[NSDictionary dictionaryWithObjectsAndKeys:srtRecipestepId,@"RecipestepId",strRecipeName,@"RecipeName",recipePicName,@"RecipestepPics",strRecipeIntro,@"RecipeIntro",strchapterId,@"RecipeChapterId", nil]];
于 2013-08-22T06:51:08.447 に答える