iPhone SDK:NSMutableArray无法识别的选择器 [英] iPhone SDK: NSMutableArray unrecognized selector

查看:44
本文介绍了iPhone SDK:NSMutableArray无法识别的选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSMutableArray,它可以从NSDictionary获取对象.这些对象的值为1或0.我试图遍历此NSMutableArray,以检查每个值.如果为1,则设置向数组添加绿色刻度图像;如果为零,则向数组添加红色十字图像.

I have an NSMutableArray which gets objects added to it from an NSDictionary. These objects are values of either 1 or 0. I am trying to loop through this NSMutableArray, to check each value. If it is 1, I set add a green tick image to an array, if it is zero, I add a red cross image to an array.

但是在检查NSMutableArray的值时出现以下错误:

However I am getting the following error on checking the values of the NSMutableArray:

[__NSArrayI isEqualToString:]: unrecognized selector sent to instance

这是我的代码:

     facilitiesAvailable = [NSMutableArray new];

     [facilitiesAvailable addObject:[[InfoDictionary valueForKey:@"wc-avail"]copy]];
     [facilitiesAvailable addObject:[[InfoDictionary valueForKey:@"wifi_avail"]copy]];

    tixArray = [NSMutableArray new];

    for(NSString *avail in facilitiesAvailable) {

        if([avail isEqualToString:@"1"]) {

            [tixArray addObject:[UIImage imageNamed:@"greenTick.png"]];
        } else {

            [tixArray addObject:[UIImage imageNamed:@"redCross.png"]];
        }

    }

我在做什么错了?

推荐答案

消息:

 [__NSArrayI isEqualToString:]: unrecognized selector sent to instance

表示 avail 是一个NSArray对象,而不是您期望的NSString,因此出现错误.您应该检查如何填充 InfoDictionary 词典,因为它来自那里.

means that avail is an NSArray object and not an NSString as you expected, hence the error. You should check how you populate your InfoDictionary dictionary, since it comes from there.

这篇关于iPhone SDK:NSMutableArray无法识别的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆