五:苹果手机开发
1:以客户数据为例,在.h文件中声明Delegate,对应hessian服务器端的客户接口,参数要数量一致。
@protocol HesGetCustomerListDelegate <NSObject>
- (NSString *)getCustomerListWithUserID:(NSString *)userID andKeyWords:(NSString *)key andPage:(int )page andPageSize:(int )psize;
@end
2:Delegate方法的声明
@property (nonatomic, strong) id<HesGetCustomerListDelegate> hesContactGetList;
3:需要导入#import "JSON.h"
4:客户数据的获取
1:以客户数据为例,在.h文件中声明Delegate,对应hessian服务器端的客户接口,参数要数量一致。
@protocol HesGetCustomerListDelegate <NSObject>
- (NSString *)getCustomerListWithUserID:(NSString *)userID andKeyWords:(NSString *)key andPage:(int )page andPageSize:(int )psize;
@end
2:Delegate方法的声明
@property (nonatomic, strong) id<HesGetCustomerListDelegate> hesContactGetList;
3:需要导入#import "JSON.h"
4:客户数据的获取
NSException *exp = nil;
int oldCnt = [arrList count];
NSURL *url = [NSURL URLWithString:SERV_URL];//SERV_URL和安卓端url是一样的
NSString *str=@"";
[CWHessianArchiver setMethodName:@"CustomerList" forSelector:aSelector];
self.hesContactGetList = (id<HesGetCustomerListDelegate>)[CWHessianConnection proxyWithURL:url
protocol:@protocol(HesGetCustomerListDelegate)];
@try {
str = [self.hesContactGetList getCustomerListWithUserID:[[NSUserDefaults standardUserDefaults] valueForKey:UID] andKeyWords:@""
andPage:curPage andPageSize:pageSize];
}
@catch (NSException *exception) {
exp = exception;
}
if (exp) {
NSLog(@"%@",exp.description);
[SVProgressHUD showErrorWithStatus:@"获取列表失败" duration:1.6f];
}
else {
NSArray *arr = [str JSONValue];
[arrList addObjectsFromArray:arr];
}
arrList 里边就包含客户的数据。
int oldCnt = [arrList count];
NSURL *url = [NSURL URLWithString:SERV_URL];//SERV_URL和安卓端url是一样的
NSString *str=@"";
[CWHessianArchiver setMethodName:@"CustomerList" forSelector:aSelector];
self.hesContactGetList = (id<HesGetCustomerListDelegate>)[CWHessianConnection proxyWithURL:url
protocol:@protocol(HesGetCustomerListDelegate)];
@try {
str = [self.hesContactGetList getCustomerListWithUserID:[[NSUserDefaults standardUserDefaults] valueForKey:UID] andKeyWords:@""
andPage:curPage andPageSize:pageSize];
}
@catch (NSException *exception) {
exp = exception;
}
if (exp) {
NSLog(@"%@",exp.description);
[SVProgressHUD showErrorWithStatus:@"获取列表失败" duration:1.6f];
}
else {
NSArray *arr = [str JSONValue];
[arrList addObjectsFromArray:arr];
}
arrList 里边就包含客户的数据。