简体   繁体   English

iOS App崩溃-无法识别的选择器发送到实例

[英]IOS App crashes - unrecognized selector sent to instance

In tableView:cellForRowAtIndexpath method, my code is as below. 在tableView:cellForRowAtIndexpath方法中,我的代码如下。

When I comment out the if condition enclosed in double asterisk(*), the app crashes with the exception mentioned below. 当我注释掉双星号(*)中包含的if条件时,应用程序崩溃,但以下提到的异常除外。 And if I uncomment it then it works fine. 如果我不加评论,那就可以了。 Please help as I am new to Objective-C. 由于我是Objective-C的新手,请提供帮助。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @“MyTableCell";

    cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@“MyTableCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }

    **if (invoiceList.count == indexPath.row  + 1)**
    {
        NSMutableDictionary *currentDictionary = [invoiceList objectAtIndex:indexPath.row];        
        cell.invoiceDetails = currentDictionary;

        for ( NSString *key in [cell.invoiceDetails allKeys]) {
            NSString *value = [cell.invoiceDetails valueForKey:key];

            if([key isEqualToString:MERCHANT_NAME]){
                cell.merchantNameValue.text  = (value == (id)[NSNull null]) ? @"" : value;
            }

            if([key isEqualToString:INVOICE_ID]){
                cell.invoiceIdValue.text  = (value == (id)[NSNull null]) ? @"" : value;
            }

            if([key isEqualToString:TOTAL_AMOUNT]){
                cell.totalAmountValue.text  = (value == (id)[NSNull null]) ? @"" : value;
            }
        }
    }

    return cell;

}

Exception thrown is: 引发的异常是:

-[__NSDictionaryM objectAtIndex:]: unrecognized selector sent to instance 0x7fc2a604e9f0
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM objectAtIndex:]: unrecognized selector sent to instance 0x7fc2a604e9f0'

*** First throw call stack:

(
0   CoreFoundation                      0x000000010fbd1f35 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x000000010f63ebb7 objc_exception_throw + 45
2   CoreFoundation                      0x000000010fbd904d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x000000010fb3127c ___forwarding___ + 988
4   CoreFoundation                      0x000000010fb30e18 _CF_forwarding_prep_0 + 120
5   MobileWalletBanking                 0x000000010cf0037f -[MyViewController tableView:cellForRowAtIndexPath:] + 479
6   UIKit                               0x000000010dd9b4b3 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
7   UIKit                               0x000000010dd7afb1 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2846
8   UIKit                               0x000000010dd90e3c -[UITableView layoutSubviews] + 213
9   UIKit                               0x000000010dd1d973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
10  QuartzCore                          0x000000010d2bade8 -[CALayer layoutSublayers] + 150
...    
)

EDIT: NSLog of invoiceList: 编辑:发票清单的NSLog:

{
    501 = 72;
    610 = Merchant1;
    611 = Merchant1;
    612 = 51573;
    615 = 51573;
    616 = "07/08/2015 00:00:00";
    617 = "64.01";
    618 = 498;
    619 = 498;
    662 =     (
                {
            501 = 72;
            520 = "15.18";
            615 = 51573;
            616 = "07/08/2015 00:00:00";
            620 = 43;
            621 = "15.18";
            623 = True;
            624 = 43;
            740 = “Text1";
        },
                {
            501 = 72;
            520 = 0;
            615 = 51573;
            616 = "07/08/2015 00:00:00";
            620 = 10;
            621 = 0;
            623 = True;
            624 = 10;
            740 = “Text2";
        },
                {
            501 = 72;
            520 = "37.63";
            615 = 51573;
            616 = "07/08/2015 00:00:00";
            620 = 2;
            621 = "37.63";
            623 = True;
            624 = 2;
            740 = “Text3";
        },
                {
            501 = 72;
            520 = "11.20";
            615 = 51573;
            616 = "07/08/2015 00:00:00";
            620 = 3;
            621 = "11.20";
            623 = True;
            624 = 3;
            740 = “Text4";
        },
                {
            501 = 72;
            520 = 0;
            615 = 51573;
            616 = "07/08/2015 00:00:00";
            620 = 14;
            621 = 0;
            623 = True;
            624 = 14;
            740 = “Text5";
        }
    );
    663 =     (
                (
                        {
                Key = 501;
                Value = 83;
            },
                        {
                Key = Name;
                Value = "INVOICE_CONNECTION_PROPERTIES";
            },
                        {
                Key = 611;
                Value = Merchant1;
            },
                        {
                Key = 610;
                Value = "";
            },
                        {
                Key = 615;
                Value = 51573;
            },
                        {
                Key = 620;
                Value = 1;
            },
                        {
                Key = "SERVICE_NAME";
                Value = “Text1";
            },
                        {
                Key = "FIELD_1";
                Value = 4272035;
            },
                        {
                Key = "FIELD_1_CONNECTION_FIELD_ID";
                Value = 000000000000481;
            },
                        {
                Key = "FIELD_1_QS_NAME";
                Value = "Id";
            },
                        {
                Key = "FIELD_1_QS_VALUE";
                Value = "Id";
            },
                        {
                Key = "FIELD_2";
                Value = 10;
            },
                        {
                Key = "FIELD_2_CONNECTION_FIELD_ID";
                Value = 000000000000482;
            },
                        {
                Key = "FIELD_2_QS_NAME";
                Value = "index1";
            },
                        {
                Key = "FIELD_2_QS_VALUE";
                Value = "index1";
            },
                        {
                Key = "FIELD_3";
                Value = "";
            },
                        {
                Key = "FIELD_3_IS_MODIFIED";
                Value = 1;
            },
                        {
                Key = "FIELD_3_CONNECTION_FIELD_ID";
                Value = 000000000000483;
            },
                        {
                Key = "FIELD_3_QS_NAME";
                Value = "index2";
            },
                        {
                Key = "FIELD_3_QS_VALUE";
                Value = "index2";
            },
                        {
                Key = "FIELD_4";
                Value = R;
            },
                        {
                Key = "FIELD_4_CONNECTION_FIELD_ID";
                Value = 000000000000488;
            },
                        {
                Key = "FIELD_4_QS_NAME";
                Value = "index_Type";
            },
                        {
                Key = "FIELD_4_QS_VALUE";
                Value = "Index_Type";
            }
        ),
                (
                        {
                Key = 501;
                Value = 83;
            },
                        {
                Key = Name;
                Value = "INVOICE_CONNECTION_PROPERTIES";
            },
                        {
                Key = 611;
                Value = Merchant1;
            },
                        {
                Key = 610;
                Value = "";
            },
                        {
                Key = 615;
                Value = 51573;
            },
                        {
                Key = 620;
                Value = 2;
            },
                        {
                Key = "SERVICE_NAME";
                Value = “Text2";
            },
                        {
                Key = "FIELD_1";
                Value = 4272033;
            },
                        {
                Key = "FIELD_1_CONNECTION_FIELD_ID";
                Value = 000000000000481;
            },
                        {
                Key = "FIELD_1_QS_NAME";
                Value = "Id";
            },
                        {
                Key = "FIELD_1_QS_VALUE";
                Value = "Id";
            },
                        {
                Key = "FIELD_2";
                Value = 3;
            },
                        {
                Key = "FIELD_2_CONNECTION_FIELD_ID";
                Value = 000000000000482;
            },
                        {
                Key = "FIELD_2_QS_NAME";
                Value = "index1";
            },
                        {
                Key = "FIELD_2_QS_VALUE";
                Value = "index1";
            },
                        {
                Key = "FIELD_3";
                Value = "";
            },
                        {
                Key = "FIELD_3_IS_MODIFIED";
                Value = 1;
            },
                        {
                Key = "FIELD_3_CONNECTION_FIELD_ID";
                Value = 000000000000483;
            },
                        {
                Key = "FIELD_3_QS_NAME";
                Value = "index2";
            },
                        {
                Key = "FIELD_3_QS_VALUE";
                Value = "index2";
            },
                        {
                Key = "FIELD_4";
                Value = C;
            },
                        {
                Key = "FIELD_4_CONNECTION_FIELD_ID";
                Value = 000000000000488;
            },
                        {
                Key = "FIELD_4_QS_NAME";
                Value = "index_type";
            },
                        {
                Key = "FIELD_4_QS_VALUE";
                Value = "index_type";
            }
        )
    );
    664 =     (
                (
                        {
                Key = 501;
                Value = 73;
            },
                        {
                Key = 625;
                Value = 000000000000481;
            },
                        {
                Key = 611;
                Value = Merchant1;
            },
                        {
                Key = 626;
                Value = "id";
            },
                        {
                Key = 627;
                Value = 1;
            },
                        {
                Key = 590;
                Value = True;
            }
        ),
                (
                        {
                Key = 501;
                Value = 73;
            },
                        {
                Key = 625;
                Value = 000000000000482;
            },
                        {
                Key = 611;
                Value = Merchant1;
            },
                        {
                Key = 626;
                Value = "index1";
            },
                        {
                Key = 627;
                Value = 2;
            },
                        {
                Key = 590;
                Value = True;
            }
        ),
                (
                        {
                Key = 501;
                Value = 73;
            },
                        {
                Key = 625;
                Value = 000000000000483;
            },
                        {
                Key = 611;
                Value = Merchant1;
            },
                        {
                Key = 626;
                Value = "index2";
            },
                        {
                Key = 627;
                Value = 3;
            },
                        {
                Key = 590;
                Value = True;
            }
        ),
                (
                        {
                Key = 501;
                Value = 73;
            },
                        {
                Key = 625;
                Value = 000000000000488;
            },
                        {
                Key = 611;
                Value = Merchant1;
            },
                        {
                Key = 626;
                Value = "index_type";
            },
                        {
                Key = 627;
                Value = 4;
            },
                        {
                Key = 590;
                Value = True;
            }
        )
    );
}

You are checking if (invoiceList.count == indexPath.row + 1) but instead of it, use if (invoiceList.count> indexPath.row ). 您正在检查是否(invoiceList.count == indexPath.row +1),但要使用if(invoiceList.count> indexPath.row)。 Please also check "numberOfRowsInIndexpath" is returning as invoiceList.count. 另请检查“ numberOfRowsInIndexpath”是否作为invoiceList.count返回。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于-[UIView _setLayerConfig:],iOS应用程序崩溃:无法识别的选择器发送到实例 - iOS App crashes because of -[UIView _setLayerConfig:]: unrecognized selector sent to instance 应用程序崩溃,错误无法识别的选择器发送到实例 - App crashes with error unrecognized selector sent to instance Titanium IOS应用程序-无法识别的选择器已发送到实例 - Titanium IOS app - unrecognized selector sent to instance iOS 8可以运行,但iOS 7会因-[NSNull长度]而崩溃:无法识别的选择器已发送到实例 - iOS 8 works but iOS 7 crashes with -[NSNull length]: unrecognized selector sent to instance iOS-ZBarSDK-应用程序崩溃,出现-[UILabel length]:无法识别的选择器发送到实例 - IOS - ZBarSDK - application crashes with -[UILabel length]: unrecognized selector sent to instance iOS-应用在“发行版”中崩溃,但不在“调试”模式下崩溃。 [__NFCString count]:无法识别的选择器已发送到实例xxx - iOS - App crashes in Release but not in Debug mode. [__NFCString count]: unrecognized selector sent to instance xxx 使用iAd时,方向更改会导致iOS 7上的应用程序崩溃(无法识别的选择器发送到实例) - Orientation change crashes app on iOS 7 when using iAd (unrecognized selector sent to instance) iPhone应用程序仅在iOS10上崩溃,且无法识别的选择器已发送至实例 - iPhone app crashes only on iOS10 with unrecognized selector sent to instance Swift 应用程序因 CLLocationManager 上的“无法识别的选择器发送到实例”而崩溃 - Swift app crashes with `unrecognized selector sent to instance` on CLLocationManager 应用程序崩溃并出现错误 [__NSCFDictionary objectAtIndex:]:无法识别的选择器发送到实例 - App crashes with error [__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM