如何解决警告的功能隐式声明的目标C

问题描述:

日志如何解决警告的功能隐式声明的目标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

时产生警告,当您尝试声明之前调用的函数。您在头文件(.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