0

セル テキストをグレー表示する前に、nsarray にデータがあるかどうかを確認しようとしていますが、何らかの理由で、恐ろしい SIGBRT を使用した if 評価で爆発しています... キー 'myIndex' が存在する場合、次のコードは正常に動作します.. .ユーザーがアプリの最後に注文を送信するときにキーを削除します....注文後にアプリが開いたときにスキップしたい?????

if(![[[inList objectAtIndex:0] objectForKey:@"myIndex"] count] == 0){

       NSArray *myIndexList = [[inList objectAtIndex:0] objectForKey:@"myIndex"];
       NSLog( @"data from INDEX !!!!!!!! %@", myIndexList);

       for(int n=0; n<[myIndexList count]; n++)
       {
           if(indexPath.row == [[myIndexList objectAtIndex:n] integerValue])
           {
               cell.textLabel.textColor = [UIColor lightGrayColor];
           }
       }

   }

お時間を割いてご協力いただき、誠にありがとうございました。

4

3 に答える 3

0

最初にinListにオブジェクトがあることを確認する必要があります。

if ([inList count] > 0) {
    if([[[inList objectAtIndex:0] objectForKey:@"myIndex"] count] > 0) {
        // there is a valid object
    }
}
于 2012-05-30T01:21:26.690 に答える
0

NSArrayに特定のオブジェクトに関するデータがあるかどうかを確認するには:

if ([[NSString stringWithFormat:@"%@", [inList objectAtIndex:0]] length] == 0) {
    //Do somthing if the NSArray object is empty.
} else {
    //Do somthing if the NSArray object countains somthing.
}

NSArray内のオブジェクトにデータがあるかどうかを確認するには:

for (int count = 0; count < inList.count; count++) {
    if ([[NSString stringWithFormat:@"%@", [inList objectAtIndex:count]] length] == 0) {
        //Do somthing if the NSArray object is empty.
    } else {
        //Do somthing if the NSArray object countains somthing.
    }
}
于 2012-05-30T01:24:46.110 に答える
0

次のようにオブジェクトが存在するかどうかを確認できます。

if([[inList objectAtIndex:0] objectForKey:@"myIndex")
{
    //It exists, do something (otherwise ignore it)
}
于 2012-05-30T01:14:11.067 に答える