objective-c 如何解决Objective C中函数的警告隐式声明
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2256554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to resolve warning implicit declaration of function in Objective C
提问by RAGOpoR
log
日志
warning: implicit declaration of function 'TutorialAlertWithMessageAndDelegate'
here my code
这是我的代码
.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];
}
回答by benzado
That warning is generated when you try to call a function before declaring it. Your declaration in the header (.h) file seems to be correct, but you are probably not including that header file in the source file that is calling the function. Be sure to put:
当您尝试在声明之前调用函数时会生成该警告。您在头文件 (.h) 中的声明似乎是正确的,但您可能没有在调用该函数的源文件中包含该头文件。一定要放:
#include "Tutorial.h" // replace with actual filename, of course
at the top of that source file.
在该源文件的顶部。

