Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone “函数“…”的隐式声明在C99中无效”_Iphone_Objective C_Ios_Xcode - Fatal编程技术网

Iphone “函数“…”的隐式声明在C99中无效”

Iphone “函数“…”的隐式声明在C99中无效”,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,我正在尝试为iphone制作一个简单的音板应用程序,但遇到了一些问题,包括函数“…”的隐式定义在C99中无效,涉及到一些不同的函数 我的.h文件如下所示: #import <UIKit/UIKit.h> #import <AudioToolbox/AudioToolbox.h> @interface ViewController : UIViewController { } - (IBAction) Jesus: (id) sender; @end #imp

我正在尝试为iphone制作一个简单的音板应用程序,但遇到了一些问题,包括函数“…”的隐式定义在C99中无效,涉及到一些不同的函数

我的.h文件如下所示:

#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>


@interface ViewController : UIViewController

{

}

- (IBAction) Jesus: (id) sender;

@end
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (IBAction) NamedAction:(id)sender: (id) sender
{
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef soundFileURLRef;
    soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"Jesus",
    CSFTR("WAV") NULL);
    if  (soundFileURLRef) {
        CFStringRef url = CFURLGetString(soundFileURLRef);
        NSLog(@"string for URl is %@", (__bridge NSString *) url);
    }

    UInt32 soundID;
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
    AudioServicesPlaySystemSound(soundID);

}


@end
我收到的错误消息是:

被调用的对象类型“int”不是函数或函数指针


您忘记将框架添加到项目中,我怀疑该框架是AudioToolBox

必须使用相同名称的变量,第二个可能是输入错误:

-iAction NamedAction:id发送者

soundFileURLRef=CbundlecopyresourceUrlMainbundle,CFStringRef@Jesus, CSFTRWAV NULL

空字符前可能缺少逗号

soundFileURLRef=CbundlecopyresourceUrlMainbundle,CFStringRef@Jesus,
CSFTRWAV,空

CSFTR有什么功能?显然,编译器从未听说过它,这是它以一种相当奇怪的方式讲述的。在C99之前,在隐式声明中使用不带声明的函数,C99将其删除

可能是您试图使用一个名称略有不同的宏


我真的建议你不要使用核心基础函数。特别是因为NSBundle和CFBundle的行为可能不同。核心基础和ARC尤其是一种组合,可以使你的大脑受到伤害,并且会导致内存泄漏或崩溃,除非你真的知道你在做什么。

< P>在其他警告标志中添加-WNO隐式函数声明,你将能够编译代码。虽然这不是一个好的解决方案,但它会起作用。

这是一个很好的解决方案。此外,将方法名称大写也不是一个好的做法。Joe,也许你可以考虑一下将来如何称呼你的函数。虽然我自己并没有被冒犯,但有一种情况是,很多人会觉得这很冒犯。