Reputation: 99
fatal error: UTF-16 (LE) byte order mark detected in '/Users/Kylegreenlaw/Downloads/Sound +/Sound +/ViewController.m', but encoding is not supported 1 error generated.
I was just in the .m file adding this
-(IBAction)buttonPressedWithSound:(id)sender {
int randomSoundNumber = arc4random() % 4; //random number from 0 to 3
NSLog(@"random NR = %i", randomSoundNumber);
NSString *effectTitle;
switch (randomSoundNumber) {
case 0:
effectTitle = @"Come at me BRO!";
break;
case 1:
effectTitle = @"sound2";
break;
case 2:
effectTitle = @"sound3";
break;
case 3:
effectTitle = @"sound4";
break;
default:
break;
}
SystemSoundID soundID;
NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle
ofType:@"mp3"];
NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];
AudioServicesCreateSystemSoundID ((CFURLRef)soundUrl, &soundID);
AudioServicesPlaySystemSound(soundID);
}
Then I went to run it but the log printed this error. What happened, and how can I fix it?
Upvotes: 0
Views: 2456
Reputation: 75058
Delete al the code in the method, and compile again - if the error goes away you have a bad character somewhere from copying code. Delete line by line until you find the line with the bad character, and re-type it.
Upvotes: 4
Reputation: 54
Make sure that you have imported all the necessary files, you may have missed to import core audio or missed to link it to the project.
Upvotes: 0