Categories
- Code (3)
- Code Snippets (12)
- git (1)
- Hardware (1)
- News (5)
- Objective-C (6)
- Precompiled (4)
- Programming (1)
- Review (1)
- Swift (9)
- Swift Standard Library (3)
- Tips (3)
- Tutorial (22)
- Uncategorized (3)
- WWDC (1)
-
Recent Posts
Meta
-
Category Archives: Code Snippets
Snippet: Sending Mail for Your App Using MFMailComposeViewController
This code snippet is a bit longer than usual but it is really useful. It can be added to a view controller to allow sending of mail to a fixed address (although the user can edit it). It could be … Continue reading
Posted in Code Snippets
Leave a comment
Snippet: Playing a System Sound
If you are using ARC see: “Playing a System Sound (ARC Version)”. Today I needed to add a simple beep sound to an app. The code snippet below shows all the relevant calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Required import... Also need AudioToolbox.framework #import <AudioToolbox/AudioToolbox.h> // ivar SystemSoundID mBeep; // Create the sound ID NSString* path = [[NSBundle mainBundle] pathForResource:@"Beep" ofType:@"aiff"]; NSURL* url = [NSURL fileURLWithPath:path]; AudioServicesCreateSystemSoundID((CFURLRef)url, &mBeep); // Play the sound AudioServicesPlaySystemSound(mBeep); // Dispose of the sound AudioServicesDisposeSystemSoundID(mBeep); |
If I had found a page … Continue reading