Je travaille toujours sur une application iPhone appelée Cruzia et je me request maintenant pourquoi je reçois ces deux avertissements, à la fois dans ViewController.m et trois erreurs, toutes une erreur Apple Mach-O Linker. Si vous pouvez me diriger dans la direction de quelques corrections je serais très reconnaissant. J'ai commenté les avertissements ci-dessous dans une copy de mon viewcontroller.m:
#import "CIAViewController.h" @interface CIAViewController() @end @implementation CIAViewController -(IBAction)press { cruzia.hidden = 0; textarea.hidden = 0; playbtn.hidden = 1; tutorialbtn.hidden = 1; optionsbtn.hidden = 1; trainingbtn.hidden = 1; back.hidden = 0; cruzia.text = @"Play"; textarea.text = @"Hello! You are playing the game of Cruzia!"; // declare defaults it is not declared elsewhere within your view controller NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // The ssortingngForKey method returns a Ssortingng and not a Boolean value // However, if you just want to check if a value exists then it is implied you are checking for existence // If there is no value then it will return nil and statement will fail // You had "== YES" outside of the parenthesis which is an illegal statement if ([defaults ssortingngForKey:kMusic]) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFSsortingngRef) @"click", CFSTR ("wav"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID); } } -(IBAction)press2 { cruzia.hidden = 0; textarea.hidden = 0; playbtn.hidden = 1; tutorialbtn.hidden = 1; optionsbtn.hidden = 1; trainingbtn.hidden = 1; back.hidden = 0; cruzia.text = @"Tutorial"; textarea.text = @"Welcome! You are watching the Cruzia tutorial!"; // declare defaults it is not declared elsewhere within your view controller NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // The ssortingngForKey method returns a Ssortingng and not a Boolean value // However, if you just want to check if a value exists then it is implied you are checking for existence // If there is no value then it will return nil and statement will fail // You had "== YES" outside of the parenthesis which is an illegal statement if ([defaults ssortingngForKey:kMusic]) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFSsortingngRef) @"click", CFSTR ("WAV"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID); } } -(IBAction)press3 { cruzia.hidden = 0; textarea.hidden = 0; playbtn.hidden = 1; tutorialbtn.hidden = 1; optionsbtn.hidden = 1; trainingbtn.hidden = 1; back.hidden = 0; cruzia.text = @"Options"; textarea.text = @"Hello! You have clicked Options. Sadly, you need to open Settngs and go to the Cruzia area to get most of the options of the game."; CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFSsortingngRef) @"click", CFSTR ("WAV"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID); } -(IBAction)press4 { cruzia.hidden = 0; textarea.hidden = 0; playbtn.hidden = 1; tutorialbtn.hidden = 1; optionsbtn.hidden = 1; trainingbtn.hidden = 1; back.hidden = 0; cruzia.text = @"Training"; textarea.text = @"This is the training area. You can improve your Cruzia skills here!"; // declare defaults it is not declared elsewhere within your view controller NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // The ssortingngForKey method returns a Ssortingng and not a Boolean value // However, if you just want to check if a value exists then it is implied you are checking for existence // If there is no value then it will return nil and statement will fail // You had "== YES" outside of the parenthesis which is an illegal statement if ([defaults ssortingngForKey:kMusic]) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFSsortingngRef) @"click", CFSTR ("WAV"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID); } } -(IBAction)press5 { cruzia.hidden = 0; textarea.hidden = 0; playbtn.hidden = 0; tutorialbtn.hidden = 0; optionsbtn.hidden = 0; trainingbtn.hidden = 0; back.hidden = 1; cruzia.text = @"Cruzia"; textarea.text = @""; // declare defaults it is not declared elsewhere within your view controller NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // The ssortingngForKey method returns a Ssortingng and not a Boolean value // However, if you just want to check if a value exists then it is implied you are checking for existence // If there is no value then it will return nil and statement will fail // You had "== YES" outside of the parenthesis which is an illegal statement if ([defaults ssortingngForKey:kMusic]) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef soundFileURLRef; soundFileURLRef =CFBundleCopyResourceURL(mainBundle, (CFSsortingngRef) @"click", CFSTR ("WAV"), NULL); UInt32 soundID; AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); AudioServicesPlaySystemSound(soundID); } } - (void)viewDidLoad { textarea.hidden = 1; playbtn.hidden = 0; tutorialbtn.hidden = 0; optionsbtn.hidden = 0; trainingbtn.hidden = 0; back.hidden = 1; cruzia.text = @"Cruzia"; [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateSettings:) name: NSUserDefaultsDidChangeNotification object:nil]; [self setupDefaults]; } - (void)viewDidUnload { [super viewDidUnload]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidFinishLaunchingNotification object:nil]; } -(void) setupDefaults { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSSsortingng *violenceValue = [defaults ssortingngForKey:kViolenceMode]; if ( violenceValue == nil ) { NSSsortingng *pathStr = [[NSBundle mainBundle] bundlePath]; NSSsortingng *settingsBundlePath = [pathStr ssortingngByAppendingPathComponent:@"Settings.bundle"]; NSSsortingng *finalPath = [settingsBundlePath ssortingngByAppendingPathComponent:@"Root.plist"]; NSDictionary *settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:finalPath]; NSArray *prefSpecifierArray = [settingsDictionary objectForKey:@"PreferenceSpecifiers"]; NSSsortingng *isMusicOn, *isSoundOn; NSDictionary *prefItem; for (prefItem in prefSpecifierArray) { NSSsortingng *keyValue = [prefItem objectForKey:@"Key"]; id defaultValue = [prefItem objectForKey:@"DeafultValue"]; if ([keyValue isEqualToSsortingng:kSound]) { isSoundOn = defaultValue; } else if ([keyValue isEqualToSsortingng:kMusic]) { isMusicOn = defaultValue; } NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: isSoundOn, kSound, isMusicOn, kMusic, nil]; [defaults registerDefaults:appDefaults]; [defaults synchronize]; } } } @end
Et voici un lien vers une capture d'écran de l'endroit où je reçois les autres erreurs avec les panneaux Debug et Output ouverts.
Merci encore, -George
Comme le journal de construction indique que ces deux symboles sont manquants:
AudioServicesCreateSystemSoundID et AudioServicesPlaySystemSound
La solution simple est qu'il semble que vous ayez besoin d'append le framework "AudioToolbox" à votre projet.