使用NSXMLParserDelegate构建项目时出错 [英] Error Building Project With NSXMLParserDelegate

查看:81
本文介绍了使用NSXMLParserDelegate构建项目时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TurbineXMLParser.h

#import <Foundation/Foundation.h>

@interface TurbineXMLParser : NSObject <NSXMLParserDelegate> {
...

TurbineXMLParser.m

#import "TurbineXMLParser.h"

我刚刚在当前项目中添加了一个新类,该类以前曾在单个文件中进行过测试.当我尝试构建项目时,出现错误:错误:找不到'NSXMLParserDelegate'的协议声明

I have just added a new class to my current project that I previously tested in a single file. When I try and build the project I get the error: error: cannot find protocol declaration for 'NSXMLParserDelegate'

我做了一些搜索,然后尝试添加以下内容...

I did a bit of searching and tried adding the following ...

TurbineXMLParser.h

#import <Foundation/Foundation.h>

@protocol NSXMLParserDelegate;

@interface TurbineXMLParser : NSObject <NSXMLParserDelegate> {
...

但仍然得到警告:警告:未找到协议"NSXMLParserDelegate"的定义

任何帮助将不胜感激

.
.
.

EDIT_002:

从@interface删除<NSXMLParserDelegate>确实可以,但是我很好奇为什么会感到困惑&糊涂了吗?我的印象是,委托对象必须采用NSXMLParserDelegate协议,即在超类之后添加<NSXMLParserDelegate>.

EDIT_002:

Removing <NSXMLParserDelegate> from the @interface did work, but I am curious as to why, am I getting mixed up & muddled? I was under the impression that the delegate object must adopt the NSXMLParserDelegate protocol i.e. adding <NSXMLParserDelegate> after the superclass.

我有两个实例,它们的工作方式不同,第一个是单个命令行文件中的项目,如果不添加<NSXMLParserDelegate>,则会警告:

I have two instances where this is working differently, the first is a project in a single command line file where If I don't add <NSXMLParserDelegate> is warns that:

class 'TestXMLParser' does not implement the 'NSXMLParserDelegate' protocol

第二个实例是当我尝试使用<NSXMLParserDelegate>构建项目时,我设置了多个* .h和* .m文件(类之一是MyXMLParser.h,MyXMLParser.m),但出现此错误:

The second instance is where I have setup multiple *.h and *.m files (one of the classes being MyXMLParser.h, MyXMLParser.m) when I try to build the project with <NSXMLParserDelegate> I get this error:

error: cannot find protocol declaration for 'NSXMLParserDelegate'

删除<NSXMLParserDelegate>,一切正常,没有错误,没有警告...

Remove <NSXMLParserDelegate> and it all works fine, no errors, no warning...

加里

推荐答案

前向声明NSXMLParserDelegate可能无济于事,如果您符合条件,则需要将其实际导入.

Forward-declaring NSXMLParserDelegate isn't likely to help, it needs to be actually imported if you're conforming to it.

如果没有将Foundation框架链接到项目中,将会得到原始错误.

The original error is what you'd get if you haven't linked the Foundation framework into your project.

在XCode中获取目标信息.在常规"选项卡中,确保Foundation.framework在链接库列表中.

Get-info your target in XCode. In the General tab, make sure Foundation.framework is in your list of linked libraries.

这篇关于使用NSXMLParserDelegate构建项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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