我的对象声明如下:
my.h
@interface My:NSObject{
NSTimeInterval time;
}
@property (assign) NSTimeInterval time;
@endmy.m
@implementation My
@synthesize time;
@end代码中的某处:
-(NSTimeInterval)getTimeInterval:(NSString*)timeStr
{
NSTimeInterval interval;
//some code
return interval;
}
-(void) func:(NSString*)timeInterval
{
My *my = [[My alloc] init];
my.time = [self getTimeInterval:timeInterval];
}在队伍中
my.time = [self getTimeInterval:timeInterval];我收到错误:“'setTime‘的参数1的类型不兼容”
谁能告诉我问题出在哪里?
发布于 2011-03-07 18:30:19
您的函数"getTimeInterval“接受一个字符串作为参数,我假定您正在向该函数传入一个NSTimeInterval / double,从而导致警告。你应该改变你的
-(NSTimeInterval)getTimeInterval:(NSString*)timeStr 获取NSTimerInterval的参数(这只是一种说double的花哨方式)。如果您打算传入时间的字符串表示形式并返回NSTimeInterval,则代码中存在错误,应该将timeInterval变量更改为包含时间的字符串变量。
发布于 2011-03-07 18:31:45
这在很多方面看起来都很奇怪。
我很确定NSTimeInterval只是一个双精度的类型定义,这使得赋值属性的定义是错误的。移除它,看看它是否正常工作。
https://stackoverflow.com/questions/5218446
复制相似问题