2012-02-09 17 views
1

我有一個iPhone應用程序使用HessianKit與我的Java服務器交談。我使用了幾個返回自定義對象的方法,但我一直無法弄清楚如何使它們作爲iPhone端正確的對象加載。HessianKit和java後端的自定義對象

這裏基本上是我有:

public class QRSet implements Serializable{ 
{ 

    protected Pagination pagination;//another custom class 
    protected int resultSetSize; 
    protected List results; 

    //...standard getters, setters, and constructors... 
} 

在Objective-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版作爲自己的類,而不是一個:

在java中

協議,但我發現映射方法的工作方式發生了變化,現在它需要這種格式:

[CWHessianArchiver setClassName:@"com.test.queries.QRSet" forProtocol:@protocol(QRSet)]; 

這是我打電話給我的服務:

id<QRSet> qrSet = [self.proxy doPaginatedList:token :filter :startingIndex]; 

然而,這是我在哪裏卡住了,如果我做我的方法調用返回QRSET,我仍然只能得到一個NSDictionary對象。有誰知道我錯過了什麼步驟讓它重新創建客戶端的QRSet對象?

+0

的問題可能是你添加翻譯'QueryResultSet',但預計結果'QRSet'。它是問題中的一種類型,還是您項目中的類型? – PeyloW 2012-03-27 20:04:16

+0

QRSet只是我在這個問題中使用的文本,(實際上它實際上是無處不在的QueryResultSet。)爲了清晰起見,我在我的問題中修正了它。 – cain 2012-04-04 14:24:15

回答

1

對於對象是從服務返回,您需要在CWHessianUnarchiver指定映射,像這樣:

[CWHessianUnarchiver setProtocol:@protocol(QRSet) forClassName:@"com.test.queries.QRSet"];