2013-02-22 82 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

你的界面無論是在接口中定義是不存在的實現方法,或者你的界面已經宣佈,它實現了一項協議,該協議已經所需的方法,並且尚未在您的實現文件中實現它們。