Friday, October 30, 2009

AVAudioRecorder prepareToRecord Silent Error

I was working on the voice record feature for one of my upcoming iPhone apps, but when I would try to start recording the app would crash.  During the adventure of debugging I couldn't trace anything back to my code as far as memory leaks, uninitialized properties, missing delegate methods, etc.  After about an hour I think I almost as many NSLog entries as I did code.  The two biggest troubling aspects where:
  1. prepareToRecord was the method that was failing
  2. AVAudioRecorder initialization wasn't throwing any errors
I turned to some sample code that I knew worked, but mine would still fail.  At this point I knew it was going to be something little that I was overlooking.  After reading through a few posts on StackOverFlow I noticed a difference in my audio configuration settings that was being passed to: initWithURL:settings:error:

I have a separate class where I set the settings argument.  The last two setting items are for: AVLinearPCMIsBigEndianKey and AVLinearPCMIsFloatKey.  Their values need to be NSNumbers so I was using [NSNumber numberWithBool:], but instead of passing in "YES" or "NO" I was passing in TRUE and FALSE, which is INCORRECT.  Just one of those oversights I forget about when switching from one language to another.

I am still not sure why my NSError wasn't populated with some information.  I don't know why the initializer didn't catch my syntax error either.

After I made my corrections, the recording worked perfectly.  Whew!  Now I just need to write the playback portion.

Posted via email from Cory Wiles Blog

Monday, October 26, 2009

Zend Framework Dynamic Site - In Production

Back in April I wrote a blog post discussing my concept of having a dynamic site using the Zend Framework.  In addition, I posted an some example code of how everything works.  I am a firm believer that one should practice what they preach and two different sites are now in production using the framework that I wrote and so far it works beautifully.  I had to make a few changes to the route to allow for module exceptions.

Towards the end of the project there was a request to have a search functionality and also custom forms.  Normally this wouldn't be an issue what so ever, but the way that the custom route is setup all requests are send to the default module/index controller/index action.  I modified the route to ignore any request that started with search or forms and route those requests to the search or forms module.  The regex is easily modified to allow for other exceptions.

Custom Regex:
<route>^(?!\bsearch|forms\b)(\w+-?[\w-?]*\/?)(.*)?</route>

I also setup the ability to add in meta keywords and meta description tags in the content.xml file.  Finally, both sites use the EXACT same doc root and dynamic site framework.  Since both sites use the same layouts, just different menus and different background images, I didn't want to duplicate a lot of code.  So in the setup page display plugin I am able to transverse the content mapping file based upon not only the request, but the url host name to display the proper layout.

Posted via email from Cory Wiles Blog

Thursday, October 8, 2009

SlideView Contribution

One of my favorite iPhone related sites to read is iPhone Developer Tips.  The tutorials are outstanding and most importantly "real world" useful.  Back in August there was a blog posted showing how to implement a "slideable" message that can be presented to a user.  After reading through it I decided to modify how it was used to make it a little more extensible for an iPhone project that I am working.  After I got everything working correctly and they way I wanted to I decided to contact the site owner, John, with all of my source code in case he wanted to use it.

After a little more tweaking to my code he posted my changes, as well as another developer, Greg's code in a new post.

This is a small example of the importance of using open source software, as well as, the importance for developers to use the knowledge and skills of other developers to make the good....GREAT.

Sliding Views On and Off Screen – Part 2 – Reader Contributions

Posted via email from Cory Wiles Blog