Links for October 25th through January 23rd Links for October 25th through January 23rd
  • Home
  • Posts
  • Home
  • Posts

Cocoa

Links for October 25th through January 23rd

Links for October 25th through January 23rd:

  • GPS Visualizer: Draw a map from a GPS data file Batch map plotter using GPS co-ordinates
  • Map multiple locations by address Very well-implemented free batch geocoder; accepts only address data, no GPS co-ordinates, but still excellent for some applications
  • iPhone: Custom font loading
  • Implementing Your Own Cocoa Bindings « Tom Dalling
Read More

Error -12986 and you

A customer recently got in touch with me with an odd problem — Talkie for iPhone was going silent on him. After a little diagnosis, it turned out the audio system was throwing up an undocumented error — -12986 — while starting up on his iPod Touch.

Some googling turned up this thread on Stack Overflow, which presented a solution for the AVAudioSession framework: It turns out, on recent SDKs (somewhere equal to or above 3.0), the audio system will refuse to start up if the session is set to a recording mode, with no input device available, spitting out this error. Alas, the error isn’t listed anywhere that I could find.

So, the way to fix it is to check whether there’s an input device available, then choose an audio category accordingly:

OSStatus status;
 
UInt32 inputAvailable=0;
UInt32 size = sizeof(inputAvailable);
AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, 
                        &size, 
                        &inputAvailable);
UInt32 sessionCategory;
if ( inputAvailable ) {
    // Set the audio session category for simultaneous play and record
    sessionCategory = kAudioSessionCategory_PlayAndRecord;
} else {
    // Just playback
    sessionCategory = kAudioSessionCategory_MediaPlayback;
}
 
status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
                                  sizeof (sessionCategory),
                                  &sessionCategory);    
checkStatus(status);

OSStatus status; UInt32 inputAvailable=0; UInt32 size = sizeof(inputAvailable); AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &inputAvailable); UInt32 sessionCategory; if ( inputAvailable ) { // Set the audio session category for simultaneous play and record sessionCategory = kAudioSessionCategory_PlayAndRecord; } else { // Just playback sessionCategory = kAudioSessionCategory_MediaPlayback; } status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory); checkStatus(status);

It’s probably a good idea to respond when input becomes available or goes away, so add a property listener too:

void inputAvailablePropertyListener (void                      *inClientData,
                                     AudioSessionPropertyID    inID,
                                     UInt32                    inDataSize,
                                     const void                *inData) {
    if ( inID = kAudioSessionProperty_AudioInputAvailable ) {
        UInt32 *inputAvailable = (UInt32*)inData;
        UInt32 sessionCategory;
        if ( *inputAvailable ) {
            // Set the audio session category for simultaneous play and record
            sessionCategory = kAudioSessionCategory_PlayAndRecord;
        } else {
            // Just playback
            sessionCategory = kAudioSessionCategory_MediaPlayback;
        }
 
        OSStatus status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
                                                   sizeof (sessionCategory),
                                                   &sessionCategory);    
        checkStatus(status);
    }
}

void inputAvailablePropertyListener (void *inClientData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData) { if ( inID = kAudioSessionProperty_AudioInputAvailable ) { UInt32 *inputAvailable = (UInt32*)inData; UInt32 sessionCategory; if ( *inputAvailable ) { // Set the audio session category for simultaneous play and record sessionCategory = kAudioSessionCategory_PlayAndRecord; } else { // Just playback sessionCategory = kAudioSessionCategory_MediaPlayback; } OSStatus status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (sessionCategory), &sessionCategory); checkStatus(status); } }

then:

// Listen for audio input availability
status = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable,
                                         inputAvailablePropertyListener, 
                                         NULL);

// Listen for audio input availability status = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable, inputAvailablePropertyListener, NULL);

Read More

Links for May 21st through June 2nd

Links for May 21st through June 2nd:

  • 49 Decent Virtual Assistant & Personal Outsourcing Resources
  • PHP: Display Adobe PSD files on a web page "Any webdesigner know the PSD filetype, which is the Adobe Photoshop format. PSDs have a lot of great features, as such as layers, but they can’t being read by a browser. Unless you use this great PHP class!"
  • Iconfinder – Icon Search Made Easy
  • Typetester – Compare fonts for the screen
  • KNAppGuide KNAppGuide is a Cocoa framework for embedding “guides” into your application, visually inspired by Apple Guide from the System 7 and 8 era
Read More

Links for March 17th through April 24th

Links for March 17th through April 24th:

  • XSD Schema XML Validator A XSD Schema validator in Java, provides lots of useful information; use it with a schema and an xml instance
  • Three20 Three20 is a collection of iPhone UI classes, like a photo viewer, and general utilities, like an HTTP disk cache. Three20 is derived from the Facebook iPhone app, which is one of the most downloaded iPhone apps ever.
  • CSS Decorative Gallery …How to decorate your images and photo galleries without editing the source images. The trick is very simple. All you need is an extra <span> tag and apply a background image to create the overlaying effect.
  • Comet (programming) – Wikipedia, the free encyclopedia Comet is a neologism to describe a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it
  • Cocoa Is My Girlfriend » Cocoa Tutorial: awakeFromNib vs applicationDidFinishLaunching A very good overview of the 'startup' procedure for objects stored in IB nib/xibs.
Read More

Links for March 6th through March 16th

Links for March 6th through March 16th:

  • CSS Code Snippets : 15 Wicked Tricks Some useful CSS tricks; of particular interest: cross-platform min-height, a trick to clear floats (without needing a 'clearing' div), and page breaks
  • 45+ New jQuery Techniques For Good User Experience Here are over 45 impressive jQuery plug-ins and techniques that have been recently created and that could make the development of your next website an easier and more interesting experience than the last.
  • How to Create a Disk Image Installer for Apple Mac OS X
  • Cocoa: Sidebar with Badges, Take 2 'Source list'-esque sidebar with support for badges
  • soultravelers3 A family of three from Santa Cruz, California on an epic odyssey: open-ended, years long slow trip around the world as a family adventure, unschool, spiritual journey and lifestyle.
Read More

Podcast interview with Dan Grigsby of Mobile Orchard on Loopy’s development

iphone-loopy-mobileorchard.pngLast Thursday I did an interview with Dan Grigsby from Mobile Orchard; the interview is now online.

Highlights from this interview include:

From UIView to OpenGL: the seven different implementations it took to finalize its unique — and Best App Ever award-nominated — UI.

From audio-queues to Remote IO: the four different architectural approaches he tried before finalizing audio subsystems.

The travails of trying to implement echo cancelation.

The business of making a living off of a $10 app

Listen to it here, or subscribe in iTunes (30 min.)

Read More

Understanding error codes

Just in case there’s someone else that didn’t know this, when one gets an error code from one of the iPhone/OS X SDKs with no other information available, it can usually be looked up in the MacErrors.h header. Just open a terminal, type:

open -h MacErrors.h

Then do a search for your error code and you’ll hopefully find a corresponding macro name that gives some indication of what went wrong.

Failing that, if you have an inkling of where the error occurred (eg. the AudioToolbox framework), then you can often find the error defined within the framework’s headers:

$ grep -r '10863' /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/Frameworks/AudioToolbox.framework/
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AUGraph.h: kAUGraphErr_CannotDoInCurrentContext = -10863,

That was, type in Terminal grep -r 'the error code', then drag the framework straight from XCode into the Terminal, where the path will be inserted.

Read More

Links for February 10th through February 27th

Links for February 10th through February 27th:

  • TinEye Reverse Image Search TinEye is a reverse image search engine. You can submit an image to TinEye to find out where it came from, how it is being used, if modified versions of the image exist, or to find higher resolution versions.
  • Traffic Shaping in Mac OS X | Mac Geekery "…Create several pipes that have a set bandwidth and other properties for all packets that get filed into them; you then add queues to those pipes that determine what priority certain requests will get in that pipe; then you add actual firewall rules to identify packets and file them into queues."
  • Brandon Walkin » Introducing BWToolkit BWToolkit is a BSD licensed plugin for Interface Builder 3 that contains commonly used UI elements and other useful objects. Using these objects is as simple as dragging them from the library to your canvas or document window. In particular, "No Code" preferences window and tabbed sheets.
  • Aussie iPhone app developers and the IRS? Discussion about tax details for Australian iPhone developers. It appears the advice from Apple on the tax form is incorrect for sales on the App Store.
  • google-toolbox-for-mac – How to do iPhone unit testing This is a quick tutorial on doing iPhone unit testing using the facilities in the Google Toolbox For Mac
Read More

Hi! I'm Michael Tyson, and I run A Tasty Pixel from our home in the hills of Melbourne, Australia. I occasionally write on a variety of technology and software development topics. I've also spent 3.5-years travelling around Europe in a motorhome.

I make Loopy, the live-looper for iOS, Audiobus, the app-to-app audio platform, and Samplebot, a sampler and sequencer app for iOS.

Follow me on Twitter.

Posts pagination

« 1 … 5 6 7 »
© 2021 A Tasty Pixel.