我有一个使用 HessianKit 与我的 java 服务器通信的 iPhone 应用程序。我使用的一些方法返回自定义对象,但我无法弄清楚如何让它们在 iPhone 端加载为正确的对象。
这基本上是我所拥有的:
在java中:
public class QRSet implements Serializable{
{
protected Pagination pagination;//another custom class
protected int resultSetSize;
protected List results;
//...standard getters, setters, and constructors...
}
在客观-c
@protocol QRSet <NSObject>
@property (strong, atomic) id<Pagination> pagination;
@property int resultSetSize;
@property (strong, atomic) NSArray * results;
//...not sure how I would need to do getters and setters here...
@end
最初我将目标 c 版本作为自己的类而不是协议,但我发现映射方法的工作方式发生了变化,现在它需要这种格式:
[CWHessianArchiver setClassName:@"com.test.queries.QRSet" forProtocol:@protocol(QRSet)];
这就是我调用我的服务的方式:
id<QRSet> qrSet = [self.proxy doPaginatedList:token :filter :startingIndex];
然而,这就是我卡住的地方,如果我调用方法来返回 QRSet,我仍然只能得到一个 NSDictionary 对象。有谁知道我缺少哪些步骤来让它在客户端重新创建 QRSet 对象?