2013-02-22 91 views
0

我所看到的其他职位,但我不知道他们在说什么。我刚开始使用Xcode,它对我来说是新的。警告只是说 “的语义问题未完全执行”未完全执行警告

#import <Foundation/Foundation.h> 
#import "classOne.h" 

@implementation classOne <------ this is where I get the Warning 

-(void) print 
{ 
    NSLog(@"I am %i years old, and weigh %i lbs.", age, weight); 
} 

-(void) setAge:(int) a 
{ 
    age = a; 
} 

-(void) setWeight: (int) w 
{ 
    weight = w; 
} 
@end 

然后.h文件低于:

#import <Foundation/Foundation.h> 

@interface classOne : NSObject { 

    int age; 
    int weight; 


} //Person: NSObject 

-(void) print; 
-(void) setAge: (int) a; //same as void setAge(int a); 
-(void) setWight: (int) w; //same as void setWeight(int a); 
@end 

的主要文件是下面这样:

#import <Foundation/Foundation.h> 
#import "classOne.h" 

int main(int argc, const char * argv[]) 
{ 

@autoreleasepool { 
    classOne *Trenton; 

    Trenton = [classOne alloc]; //reserves memory for the object Trenton 
    Trenton = [Trenton init]; //initalizes the object 

    [Trenton setAge: 25]; 
    [Trenton setWight: 230]; 
    [Trenton print]; 
    //[Trenton release]; //release frees any memory we borrowed from alloc 
} 
return 0; 
} 
+1

它可能意味着你的classOne.m中缺少classOne.h – 2013-02-22 21:11:33

+0

宣称可以提供wanring文本的方法。我怀疑你缺少部分属性。 – madmik3 2013-02-22 21:12:39

+0

单击带有感叹号的黄色三角形标记。然后点击“在问题导航器中显示”,xcode会告诉您在实现类时缺少的内容。 – 2013-02-22 21:23:23

回答

1

您需要拼写方法在@interface并在@implementation相同。看起来你在setWeight:

-(void) setWight: (int) w; //same as void setWeight(int a); 

忘了e编译器警告你,因为,在此基础上错字在你的@interface声明,该公司预计,为您实现一个名为setWight:方法,但你已经实现setWeight:

+0

我以为是小事.....谢谢 – DDukesterman 2013-02-22 21:27:05

2

在Xcode,在左侧边栏的警告标签中找到警告(它是左起第4个图标,看起来像/!\),然后单击它旁边的小三角形。它会列出所有缺少的方法。

+0

三角形旁边没有太多提及。但有一些像“在问题导航器中显示”。然后,问题导航器将提供所有详细信息,尤其是缺少方法的名称。 – 2013-02-22 21:22:17

+0

@HermannKlecker,旁边的三角形是一样的消息,但如果你点击那个三角形,你会使用问题导航仪获取的未实现的方法列表,就像你。 – zneak 2013-02-22 21:42:19

0

你的界面无论是在接口中定义是不存在的实现方法,或者你的界面已经宣布,它实现了一项协议,该协议已经所需的方法,并且尚未在您的实现文件中实现它们。