错误:QTGetTimeInterval的参数1的不兼容类型

时间:2011-02-01 15:10:53

标签: objective-c

这部分代码仍有问题:

@interface MYAccessMp3Tags: NSObject
{
    NSTimeInterval duration;
    NSTimeInterval currentTime;
}

-(NSTimeInterval) durationInSeconds;
-(NSTimeInterval) currentTimeInSeconds;
-(NSDictionary *) metadata;
-(NSString *) metadataDescription;
-(NSString *) loadStateDescription;

@property (nonatomic) NSTimeInterval duration;
@property (nonatomic) NSTimeInterval currentTime;
@end



@implementation MYAccessMp3Tags;

@synthesize duration;
@synthesize currentTime;
-(NSTimeInterval)durationInSeconds 
{

    NSTimeInterval dur;

    QTGetTimeInterval([self duration], &dur);
    //error: incompatible type for argument 1 of QTGetTimeInterval
    return duration;
}

-(NSTimeInterval)currentTimeInSeconds 
{
    NSTimeInterval currTime;
    QTGetTimeInterval([self currentTime], &currTime);
    //error: incompatible type for argument 1 of QTGetTimeInterval
    return currentTime;
}     

这里有什么问题?

1 个答案:

答案 0 :(得分:0)

我确定您不想使用[self currentTime]。这将返回您在currentTime中定义的属性.h,即NSTimeInterval。你为什么要把它归入QTGetTimeInterval

相反,我确定您希望获得duration个实例的currentTimeQTMovie

所以,假设你有QTMovie*movie。然后,[movie duration]返回QTTime,而不是NSTimeInverval。这是因为,从历史上看,QuickTime源自Cocoa / Objective-C的不同来源。这就是为什么你需要像QTGetTimeInterval这样的转换函数。所以,

QTMovie*movie= ... ;
QTTime duration=[movie duration]; 
NSTimeInterval dur;
QTGetTimeInterval(duration, &dur);

应该有用。