2013-10-09 56 views
0

服务hessiankit例外NSRangeException

@protocol Service <NSObject> 
-(int)getPersonCount; 
-(id<Person>)getPerson:(int)index; 
@end 

协议

@protocol Person 
@property(assign, nonatomic) int age; 
@property(retain, nonatomic) NSString* name; 
@end 

代理以这种方式

id<Service> proxy = [CWHessianConnection proxyWithURL:url protocol:@protocol(Service)]; 
    int count = [proxy getPersonCount]; 
    for (int index = 0; index < count; index++) { 
     id<Person> person = [proxy getPerson:index]; 
     NSLog(@"age: %d name: %@", person.age, person.name); 
    } 

结果是[__NSCFData getBytes:range:]: range {3, 1}制成超过数据长度3

这是来自HessianKit doc的示例代码,我不知道它有什么问题。

回答

0

您只是访问超出范围的数据。最大范围应该是{2,1},而你正试图达到3.

+0

但是我不是直接由我自己控制的数组,它是hessiankit本身。 – chengjj520