#import
#import
@ interface BickboxxViewController : UIViewController {
CFURLRef bNoteFileURLRef;
SystemSoundID bNoteFileObject;
CFURLRef eNoteFileURLRef;
SystemSoundID eNoteFileObject;
CFURLRef aNoteFileURLRef;
SystemSoundID aNoteFileObject;
CFURLRef tNoteFileURLRef;
SystemSoundID tNoteFileObject;
}
@property (readwrite) CFURLRef bNoteFileURLRef;
@property ( readonly ) SystemSoundID bNoteFileObject;
@property (readwrite) CFURLRef eNoteFileURLRef;
@property ( readonly ) SystemSoundID eNoteFileObject;
@property (readwrite) CFURLRef aNoteFileURLRef;
@property ( readonly ) SystemSoundID aNoteFileObject;
@property (readwrite) CFURLRef tNoteFileURLRef;
@property ( readonly ) SystemSoundID tNoteFileObject;
@end
* This source code was highlighted with Source Code Highlighter .
@synthesize bNoteFileURLRef, bNoteFileObject, eNoteFileURLRef,
eNoteFileObject, aNoteFileURLRef, aNoteFileObject,
tNoteFileURLRef, tNoteFileObject;
* This source code was highlighted with Source Code Highlighter .
// bundle
CFBundleRef mainBundle;
mainBundle = CFBundleGetMainBundle ();
* This source code was highlighted with Source Code Highlighter .
// ,
AudioServicesCreateSystemSound // URL
bNoteFileURLRef = CFBundleCopyResourceURL (
mainBundle,
CFSTR ( "B" ),
CFSTR ( "aifc" ),
NULL
);ID (bNoteFileURLRef, &bNoteFileObject);
* This source code was highlighted with Source Code Highlighter .
// ,
AudioServicesCreateSystemSoundID (bNoteFileURLRef, &bNoteFileObject);
* This source code was highlighted with Source Code Highlighter .
// viewDidLoad , nib-
- ( void )viewDidLoad {
[super viewDidLoad];
// bundle
CFBundleRef mainBundle;
mainBundle = CFBundleGetMainBundle ();
// URL
bNoteFileURLRef = CFBundleCopyResourceURL (
mainBundle,
CFSTR ( "B" ),
CFSTR ( "aifc" ),
NULL
);
//
AudioServicesCreateSystemSoundID (bNoteFileURLRef, &bNoteFileObject);
// URL
eNoteFileURLRef = CFBundleCopyResourceURL (
mainBundle,
CFSTR ( "E" ),
CFSTR ( "aifc" ),
NULL
);
//
AudioServicesCreateSystemSoundID (eNoteFileURLRef, &eNoteFileObject);
// URL
aNoteFileURLRef = CFBundleCopyResourceURL (
mainBundle,
CFSTR ( "A" ),
CFSTR ( "aifc" ),
NULL
);
//
AudioServicesCreateSystemSoundID (aNoteFileURLRef, &aNoteFileObject);
// URL
tNoteFileURLRef = CFBundleCopyResourceURL (
mainBundle,
CFSTR ( "T" ),
CFSTR ( "aifc" ),
NULL
);
//
AudioServicesCreateSystemSoundID (tNoteFileURLRef, &tNoteFileObject);
}
* This source code was highlighted with Source Code Highlighter .
- (IBAction)bSound:(id)sender;
- (IBAction)eSound:(id)sender;
- (IBAction)aSound:(id)sender;
- (IBAction)tSound:(id)sender;
* This source code was highlighted with Source Code Highlighter .
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>
@ interface BickBoxxViewController : UIViewController {
CFURLRef bNoteFileURLRef;
SystemSoundID bNoteFileObject;
CFURLRef eNoteFileURLRef;
SystemSoundID eNoteFileObject;
CFURLRef aNoteFileURLRef;
SystemSoundID aNoteFileObject;
CFURLRef tNoteFileURLRef;
SystemSoundID tNoteFileObject;
}
@property (readwrite) CFURLRef bNoteFileURLRef;
@property ( readonly ) SystemSoundID bNoteFileObject;
@property (readwrite) CFURLRef eNoteFileURLRef;
@property ( readonly ) SystemSoundID eNoteFileObject;
@property (readwrite) CFURLRef aNoteFileURLRef;
@property ( readonly ) SystemSoundID aNoteFileObject;
@property (readwrite) CFURLRef tNoteFileURLRef;
@property ( readonly ) SystemSoundID tNoteFileObject;
//
- (IBAction)bSound:(id)sender;
- (IBAction)eSound:(id)sender;
- (IBAction)aSound:(id)sender;
- (IBAction)tSound:(id)sender;
@end
* This source code was highlighted with Source Code Highlighter .
- (IBAction)bSound:(id)sender {
AudioServicesPlaySystemSound (self.bNoteFileObject);
}
* This source code was highlighted with Source Code Highlighter .
#import "BickBoxxViewController.h" </span>
@implementation BickBoxxViewController
@synthesize bNoteFileURLRef, bNoteFileObject, eNoteFileURLRef,
eNoteFileObject, aNoteFileURLRef, aNoteFileObject,
tNoteFileURLRef, tNoteFileObject;
- (IBAction)bSound:(id)sender {
AudioServicesPlaySystemSound (self.bNoteFileObject);
}
- (IBAction)eSound:(id)sender {
AudioServicesPlaySystemSound (self.eNoteFileObject);
}
- (IBAction)aSound:(id)sender {
AudioServicesPlaySystemSound (self.aNoteFileObject);
}
- (IBAction)tSound:(id)sender {
AudioServicesPlaySystemSound (self.tNoteFileObject);
}
* This source code was highlighted with Source Code Highlighter .
- ( void )dealloc {
[super dealloc];
AudioServicesDisposeSystemSoundID (self.bNoteFileObject);
AudioServicesDisposeSystemSoundID (self.eNoteFileObject);
AudioServicesDisposeSystemSoundID (self.aNoteFileObject);
AudioServicesDisposeSystemSoundID (self.tNoteFileObject);
CFRelease (bNoteFileURLRef);
CFRelease (eNoteFileURLRef);
CFRelease (aNoteFileURLRef);
CFRelease (tNoteFileURLRef);
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/70800/