NStimeInterval属性错误
我的对象声明如下:
my.h
@interface My:NSObject{
NSTimeInterval time;
}
@property (assign) NSTimeInterval time;
@end
my.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的不兼容类型”
谁能告诉我问题出在哪里?
没有找到相关结果
已邀请:
2 个回复
响摔衅幸
获取NSTimerInterval的参数(这只是一种说法加倍的奇特方式)。如果你想传递一个时间的字符串表示并返回NSTimeInterval,你的代码中就会出现错误,并且应该将timeInterval变量更改为包含你的时间的字符串变量。
稼悸