dejo helped me find the syntax for system sound.
His code worked perfectly, as did the code when I modified it to make my test code before inserting it in the project I am working on.
dejo's code worked perfectly. My modifications of dejo's code worked perfectly. However, when I inserted the perfectly working modificed code in my project it did not work.
Below you will find the same code. The first works the second fails to compile.
I first suspected something conflicted with it. I looked for three days and tested everything from file names to the project bundle. I can find nothing. Finally I attempted a fresh test code. After trying my modified code fresh and the started a new project using dejo's original code again, it didn't work either. It gave me the same error as the project in which I was inserting the working code.
The first test project I made with dejo's code still works. Additional test projects I made with the same code from dejo don't work and give me the same compiler errors. Obviously, for the same code to work once and not to work the next time, I am missing some compiler option or setting which I happened to get right the first time and never again.
The working code follows then the code which does not work. (yes. they are the same code, but the first ones works and the second does not.
Hopefully someone will see the problem right away and be able to pin it down. I am stumped.
This code compiles and plays the GuitarScale properly.
This code, however, does not compile and gives the error below:
This second code gives me this compiler error quoted verbatum:
collect2: Id returned 1 exit status
symbol(s) not found
-[SecTestViewController viewDidLoad] in SecTestViewController.o
"*AudioServicesCreateSystemSoundID", referenced from:
-[SecTestViewController viewDidLoad] in SecTestViewController.o
"*AudioServicesPlaySystemSound", referenced from:
end quote:
His code worked perfectly, as did the code when I modified it to make my test code before inserting it in the project I am working on.
dejo's code worked perfectly. My modifications of dejo's code worked perfectly. However, when I inserted the perfectly working modificed code in my project it did not work.
Below you will find the same code. The first works the second fails to compile.
I first suspected something conflicted with it. I looked for three days and tested everything from file names to the project bundle. I can find nothing. Finally I attempted a fresh test code. After trying my modified code fresh and the started a new project using dejo's original code again, it didn't work either. It gave me the same error as the project in which I was inserting the working code.
The first test project I made with dejo's code still works. Additional test projects I made with the same code from dejo don't work and give me the same compiler errors. Obviously, for the same code to work once and not to work the next time, I am missing some compiler option or setting which I happened to get right the first time and never again.
The working code follows then the code which does not work. (yes. they are the same code, but the first ones works and the second does not.
Hopefully someone will see the problem right away and be able to pin it down. I am stumped.
This code compiles and plays the GuitarScale properly.
Code:
// file SysSoundViewController.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
@interface SysSoundViewController : UIViewController {
SystemSoundID theSoundFile;
}
@property (readwrite) SystemSoundID theSoundFile;
@end
// file SysSoundViewController.m
#import "SysSoundViewController.h"
@implementation SysSoundViewController
@synthesize theSoundFile;
- (void) viewDidLoad {
AudioServicesCreateSystemSoundID( CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR( "GuitarScale"), CFSTR( "wav"), NULL), &theSoundFile);
AudioServicesPlaySystemSound(self.theSoundFile);
[super viewDidLoad];
}
- (void) dealloc {
[super dealloc];
}
@end
This code, however, does not compile and gives the error below:
Code:
// file SecTestViewController.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
@interface SecTestViewController : UIViewController {
SystemSoundID theSoundFile;
}
@property (readwrite) SystemSoundID theSoundFile;
@end
// file SecTestViewController.m
#import "SecTestViewController.h"
@implementation SecTestViewController
@synthesize theSoundFile;
- (void)viewDidLoad {
AudioServicesCreateSystemSoundID( CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR( "GuitarScale"), CFSTR( "wav"), NULL), &theSoundFile);
AudioServicesPlaySystemSound(self.theSoundFile);
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[super dealloc];
}
@end
This second code gives me this compiler error quoted verbatum:
collect2: Id returned 1 exit status
symbol(s) not found
-[SecTestViewController viewDidLoad] in SecTestViewController.o
"*AudioServicesCreateSystemSoundID", referenced from:
-[SecTestViewController viewDidLoad] in SecTestViewController.o
"*AudioServicesPlaySystemSound", referenced from:
end quote: