Silent Mode Switch and Playing Sounds

In a previous tip, Playing Short Sounds, I wrote an example to show how you can play a short sound, up to 30 seconds, by calling one of the C-based functions in the Audio Session Services library.

There is one aspect of this that can be troublesome - by default, playing an Audio Session sound will ~not~ respect the setting of the mute switch on the iPhone. In other words, if you make a call to play a sound and the silent (hardware) switch on the iPhone is set to silent, you’ll still hear the sound.

Continue reading this post »

Audio

iPhone SDK 3 and Deprecated Method Warnings

A side-effect of developing code on platforms that continue to evolve, is dealing with methods that become deprecated from one release to another. If you’ve spent anytime at all with Java, you are all too familiar with this concept. With the release of the iPhone SDK version 3.0, a number of methods have been become subject to the same fate.

Here is how I came about this in my most recent app. I have a subclass of UITableViewCell that looks as follows:

Continue reading this post »

Cocoa

Snoop Dogg App on the iPhone - iFizzle

I recently completed an iPhone application for Snoop Dogg. Check this out: Snoop did a demo of the application on the Tonight Show with Conan O’Brien.

If you interested to learn more about the app, or have an idea for something similar you would like developed, drop me a note. You can also visit 3 Sixty Software, the business end of my iPhone development.

Announcements

Playing Short Sounds - Audio Session Services

If you need to play short sounds, less than 30 seconds, Audio Session Services are your friend. Here is a snippet of code to play a wav file:

SystemSoundID soundID;
NSString *path = [[NSBundle mainBundle]
   pathForResource:@"RapidFire" ofType:@"wav"];    
 
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path],&soundID);
AudioServicesPlaySystemSound (soundID);


Continue reading this post »

Audio

Xcode, Folders and the File System - Part 2

In Part 1 of Xcode, Folders and the File System I walked through a short example on how to import folders into Xcode such that resources within a project have a folder structure that matches the file system.

In this post I will show you two ways to access the imported resources, one by specifying a path, one using an application bundle, both examples will focus on working with images. The code below is an example of building a path to a resource, avoiding a hardcoded path by using index values maintained within the application.

Continue reading this post »

Xcode

Xcode, Folders and the File System - Part 1

Xcode provides a built in mechanism for organzing content within a project (control-click or right click -> Add -> New Group). For example, in the image below, I’ve created a number of groups for separating the primary functionality of an application into model classes and views.

Although this is nice, for the most part the file structure as stored on the system is still flat. In other words, Xcode manages this information internally, it does not create corresponding folders on the file system.

Continue reading this post »

Xcode

UIColor Macros

Below are two macros I paste inside every new iPhone project. Besides saving a few keystrokes, they work well when using the color picker application. Let’s look at the macros first:

 #define RGB(r, g, b) 
    [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
 #define RGBA(r, g, b, a) 
    [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

Here’s the code without/with the macro:

Continue reading this post »

Cocoa