小编Mat*_*van的帖子

iOS应用程序崩溃 - [NSURL initFileURLWithPath:]

我是一个业余的ios开发人员,版本4.6的xcode和OSX 10.8.4.我正在尝试制作一个播放声音的应用程序但是当我尝试运行该应用程序时,我收到此消息:

*由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'* - [NSURL initFileURLWithPath:]:nil string parameter'

我的应用程序也不会启动.

这是我的视图controller.h的代码:

      ViewController.h:

 #import <UIKit/UIKit.h>
#import <RevMobAds/RevMobAds.h>
#import <AVFoundation/AVFoundation.h>


@interface ViewController : UIViewController 



- (IBAction)playButton:(id)sender;
- (IBAction)stopButton:(id)sender;

@end
Run Code Online (Sandbox Code Playgroud)

这是我的视图controller.m:

      Viewcontroller.m:


#import "ViewController.h"
#import <RevMobAds/RevMobAds.h>


@interface ViewController ()
{
AVAudioPlayer *avPlayer;
}
@end

@implementation ViewController 
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *stringPath = [[NSBundle mainBundle]pathForResource:@"98648__dobroide__20100606-mosquito" ofType:@"mp3"];

NSURL *url = [NSURL fileURLWithPath:stringPath];

NSError *error;

avPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];

[avPlayer setNumberOfLoops:-1]; …
Run Code Online (Sandbox Code Playgroud)

macos compiler-errors objective-c ios

1
推荐指数
1
解决办法
4161
查看次数

标签 统计

compiler-errors ×1

ios ×1

macos ×1

objective-c ×1