Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.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
如何在iPhone中取消自定义协议_Iphone_Hessian - Fatal编程技术网

如何在iPhone中取消自定义协议

如何在iPhone中取消自定义协议,iphone,hessian,Iphone,Hessian,我想使用一个协议,我们如何在iPhone中实现它 ///在POCViewController.h中 #进口 @BasicAPI协议 -(NSString*)你好; @结束 @接口HessianPOCViewController:UIViewController { 伊巴西卡皮 } @结束 /// //在POCViewController.m中 //以某种方式 NSURL*url=[NSURL URLWithString@“] 身份代理= (id)[CWHESSIAN连接 proxyWithURL

我想使用一个协议,我们如何在iPhone中实现它

///在POCViewController.h中

#进口

@BasicAPI协议 -(NSString*)你好; @结束 @接口HessianPOCViewController:UIViewController { 伊巴西卡皮

}

@结束

///

//在POCViewController.m中 //以某种方式

NSURL*url=[NSURL URLWithString@“]

身份代理= (id)[CWHESSIAN连接 proxyWithURL:url 协议:@协议(basicAPI)]

NSLog(@“hello:%@,[proxy hello])

////


请帮助我如何实现上述代码?

在上面的代码片段中,@protocol块位于头文件中,在已经存在的@end声明下面。常见用例类似于:

@interface MyClass
// properties, method definitions, etc
@end

@protocol BasicAPI

-(NSString*)hello;

@end
然后在实现文件中的某个方法体中,MyClass.m

-(void)myMethod { 
   NSURL* url = [NSURL URLWithString@"http://www.caucho.com/hessian/test/basic"];
   id proxy = (id)[CWHessianConnection proxyWithURL:url protocol:@protocol(basicAPI)];
   NSLog(@"hello: %@", [proxy hello]);
}

我看到您给出的示例是从本项目的文档中获取的。它向您展示了如何从Objective-C客户机与Hessian web服务交互


您是否有正在尝试与之交谈的现有Hessian web服务?如果是这样,您需要在
@协议中声明
阻止该服务的接口。答案给出了一些很好的例子,说明这在客户端和服务器端是如何工作的。

这是一个不起作用的错误:“找不到BasicApi的协议声明”@iPhoneDev检查您的大写字母(BasicApi vs.BasicApi)(并确保您包含了.h文件)opsss抱歉,我的不好。。。将“BasicApi”更改为“BasicApi”,非常感谢:)