[MonoTouch] Attempting to use AVFoundation for recording

Adam Langley alangley at winscribe.com
Thu Oct 8 16:14:57 EDT 2009


I am trying to do some simple recording with the AVAudioRecorder, and I
was hoping someone could give me some pointers.

Firstly, some of the methods, such as the AVAudioRecorder constructor,
and AVAudioSession.SetCategory take an NSError argument, which must be
non-null.
I have found samples on the net of using NSError which look like this:

NSError error = null;
obj.CallMethod(argument, out error);

Which makes perfect sense, but, the AVFoundation ones don't take the
error as an out arg, so I must pass them like this

NSError error = new NSError();
recorder = new AVAudioRecorder(url, dict, error);

which doesn't seem quite right - how do I test if there was an error?
When I reference any members of the error object, such as the 'Code' or
'LocalizedDescription' properties, I get a massive seg-fault...

So, what is the practice for using NSError with classes in this
namespace?

Thanks!

Adam Langley


More information about the MonoTouch mailing list