我尝试编写自定义 setter 方法,但失败并显示错误消息"Type of property 'pValue' does not match type of accessor 'setPValue:'"
。数组已成功传递,但我不明白错误消息。
我的 .h 文件:
@property (nonatomic, assign) double pValue;
- (double)getInverseCDFValue:(double)p;
- (void)setPValue:(NSArray*)aArray;
我的实现:
@synthesize pValue;
- (void)setPValue:(NSArray *)aArray {
double p = [[aArray objectAtIndex:22]doubleValue];
NSLog(@"p is: %f", p); //the value is written successfully
[self getInverseCDFValue:p]; //just calling another method for calculations
pValue = iCFDValue;
}
它适用于传递单个值,但不适用于数组。这在setter方法中是不允许的吗?
谢谢