Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 已将无法识别的选择器发送到Tableviewcontroller中的实例_Ios_Objective C_Uitableview_Unrecognized Selector - Fatal编程技术网

Ios 已将无法识别的选择器发送到Tableviewcontroller中的实例

Ios 已将无法识别的选择器发送到Tableviewcontroller中的实例,ios,objective-c,uitableview,unrecognized-selector,Ios,Objective C,Uitableview,Unrecognized Selector,好的,我正在尝试创建一个简单的TableView应用程序,当选中该行时,它将转换为WebView。我使用的故事板,并有我的链接正确连接。我得到了一个类似下面的错误。我一直在关注Lynda.com上的教程,还有一个来自Lynda.com的教程,两个教程都使用了我在下面尝试过的方法,即使用“Guide”或他们与NSObject的类的任何标题。我真的很困惑,因为我不明白为什么它不会认出它。我尝试过删除@property(非原子,强)Guide*html;分开,但仍然得到同样的信息。我希望这对你来说足够

好的,我正在尝试创建一个简单的TableView应用程序,当选中该行时,它将转换为WebView。我使用的故事板,并有我的链接正确连接。我得到了一个类似下面的错误。我一直在关注Lynda.com上的教程,还有一个来自Lynda.com的教程,两个教程都使用了我在下面尝试过的方法,即使用“Guide”或他们与NSObject的类的任何标题。我真的很困惑,因为我不明白为什么它不会认出它。我尝试过删除@property(非原子,强)Guide*html;分开,但仍然得到同样的信息。我希望这对你来说足够具体。哦,我正在使用最新版本的xcode

我的错误消息是

-[Guide isEqualToString:]: unrecognized selector sent to instance 0x8543aa0
2013-05-05 11:33:29.076 hikingHelp[5522:c07] *** Terminating app due to uncaught exception    NSInvalidArgumentException', reason: '-[Guide isEqualToString:]: unrecognized selector 
sent to instance 0x8543aa0'
*** First throw call stack:
我的Guide.h文件如下:

#import <Foundation/Foundation.h>
#import "TableViewController.h"
#import "DetailViewController.h"
#import "MapViewController.h"


@interface Guide : NSObject

@property (nonatomic, strong) NSString *htmlListName;
@property (nonatomic, strong) NSString *htmlFileName;

@end

Guide是一个类,它不是一个字符串,因此它如何将类与字符串进行比较。

您正在调用方法
isEqualToString:
,该方法在您的自定义对象
Guide
类型的NSString实例上定义

正如类指南isEqualToString所示:您得到一个错误

  • 要么你在某个地方错误地与一位导游合作,认为这是一个强大的团队
  • 或者您向某个方法(可能来自tableView数据源)传递一个指南,它通常采用字符串

出现错误的原因是,您正在从数组中检索向导实例,认为您正在
-cellforrowatinexpath:
方法中接收
htmlFileName
htmlListName

而不是使用
cell.textLabel.text=[htmlFiles objectAtIndex:indexPath.row],请使用以下命令:

Guide *rowGuide = htmlFiles[indexPath.row];
cell.textLabel.text = rowGuide.htmlFileName;
此外,您可以使用for循环或NSFastEnumeration,而不是在
-viewDidLoad
方法中手动设置实例化每个指南实例:

- (void)viewDidLoad {
    [super viewDidLoad];

    htmlFiles = [[NSMutableArray alloc] init];

    NSArray *htmlListNames = @[@"Survival Planning", @"Survival Kits", @"Basic Survivl Medicine", @"Shelters", @"Water Procurement", @"Firecraft", @"Food", @"Edible Plants", @"Poisonous Plants", @"Dangerous Animals", @"Water Crossing", @"Find Directions", @"Signalling Technique"];
    NSArray *htmlFileNames = @[@"survivalplanning.html", @"survivalkits.html", @"basichealth.html", @"shelters.html", @"waterprocurement.html", @"firecraft.html", @"food.html", @"edibleplant.html", @"posionousplants.html", @"dangerousanimals.html", @"watercrossings.html", @"directions.html", @"signaling.html"];

    for (NSUInteger idx = 0; idx < [htmlListNames count]; idx++) {
        Guide *guide = [[Guide alloc] init];
        [guide setHtmlListName:htmlListNames[idx]];
        [guide setHtmlFileName:htmlFileNames[idx]];
        [htmlFiles addObject:guide];
        [guide release]; // if you're not using arc
    }
}
-(void)viewDidLoad{
[超级视图下载];
htmlFiles=[[NSMutableArray alloc]init];
NSArray*htmlListNames=@[“生存规划”,“生存工具包”,“基本生存药物”,“避难所”,“水采购”,“消防车”,“食品”,“食用植物”,“有毒植物”,“危险动物”,“水穿越”,“寻找方向”,“信号技术];
NSArray*htmlFileNames=@[@“survivalplanning.html”、@“survivalkits.html”、@“basichealth.html”、@“hedders.html”、@“waterprocurement.html”、@“firecraft.html”、@“food.html”、@“edibleplant.html”、@“posionusplants.html”、@“dangerouseals.html”、@“watercrossings.html”、@“directions.html”、@“signing.html”];
对于(整数idx=0;idx<[htmlListNames计数];idx++){
Guide*Guide=[[Guide alloc]init];
[指南设置HTMLListName:htmlListNames[idx]];
[指南设置HTMLFileName:HTMLFileName[idx]];
[HtmlFilesAddObject:guide];
[指南发布];//如果不使用arc
}
}

您的UITableView代码在哪里?您是否在任何地方检查
IsequalString
。哪一行代码导致了异常?您发布的代码都没有导致错误。您是否支持loop bro?获取两个nsarray,一个用于htmlistname(NSStrings),另一个用于htmlFileName。循环遍历其中一个数组,创建一个Guide实例,每次都将其添加到数组中?请在这里发布你的Guide.m代码。@max刚刚开始,所以我从来没有想过使用for循环。在制作我自己版本的应用程序时,我只是想通过一些教程了解一些基本知识。字符串也是一个类。。。您的问题是对的,但您的答案表述不正确Guide是NSObject的子类您可以[guideObj.htmlFileName IsequalString:@“Matchedstring”];非常感谢你!另外,我要去谷歌如何设置一个for循环中的数组,所以也谢谢你的关注!
-[Guide isEqualToString:]
Guide *rowGuide = htmlFiles[indexPath.row];
cell.textLabel.text = rowGuide.htmlFileName;
- (void)viewDidLoad {
    [super viewDidLoad];

    htmlFiles = [[NSMutableArray alloc] init];

    NSArray *htmlListNames = @[@"Survival Planning", @"Survival Kits", @"Basic Survivl Medicine", @"Shelters", @"Water Procurement", @"Firecraft", @"Food", @"Edible Plants", @"Poisonous Plants", @"Dangerous Animals", @"Water Crossing", @"Find Directions", @"Signalling Technique"];
    NSArray *htmlFileNames = @[@"survivalplanning.html", @"survivalkits.html", @"basichealth.html", @"shelters.html", @"waterprocurement.html", @"firecraft.html", @"food.html", @"edibleplant.html", @"posionousplants.html", @"dangerousanimals.html", @"watercrossings.html", @"directions.html", @"signaling.html"];

    for (NSUInteger idx = 0; idx < [htmlListNames count]; idx++) {
        Guide *guide = [[Guide alloc] init];
        [guide setHtmlListName:htmlListNames[idx]];
        [guide setHtmlFileName:htmlFileNames[idx]];
        [htmlFiles addObject:guide];
        [guide release]; // if you're not using arc
    }
}