2010-02-13 55 views
11

日誌如何解決警告的功能隱式聲明的目標C

warning: implicit declaration of function 'TutorialAlertWithMessageAndDelegate' 

這裏我的代碼

.h 

void TutorialAlertWithMessageAndDelegate(NSString *title, NSString *message, id delegate); 


.m 
void TutorialAlertWithMessageAndDelegate(NSString *title, NSString *message, id delegate) 
{ 
    /* open an alert with OK and Cancel buttons */ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title 
                message:message 
                delegate:delegate 
              cancelButtonTitle:@"Dismiss" 
              otherButtonTitles: @"Show Tutorial", @"Disable Tutorial", nil]; 
    // otherButtonTitles: @"Show Next Tip", @"Disable Tips", nil]; 
    [alert show]; 
    [alert release]; 
} 
+1

我需要生成該警告的代碼,而不是定義函數的代碼:問題出在哪裏。 – 2010-02-13 05:14:13

回答

12

時產生警告,當您嘗試聲明之前調用的函數。您在頭文件(.h)文件中的聲明似乎是正確的,但是您可能沒有在調用該函數的源文件中包含該頭文件。請務必在該源文件的頂部放置:

#include "Tutorial.h" // replace with actual filename, of course 

+1

謝謝,我忘了包括它,但爲什麼它也工作? – RAGOpoR 2010-02-13 05:20:40

+5

C不要求你聲明函數,儘管這是最佳實踐。這就是爲什麼它只給了你一個警告,而不是一個錯誤。 – benzado 2010-02-13 05:49:09

+0

謝謝benzado^_ ^ – RAGOpoR 2010-02-13 06:24:48

相關問題