Re: How to get bundle for pAudioUnit (in Objective-C)?
Re: How to get bundle for pAudioUnit (in Objective-C)?
- Subject: Re: How to get bundle for pAudioUnit (in Objective-C)?
- From: Howard Moon <email@hidden>
- Date: Mon, 7 Feb 2011 15:12:46 -0800
On Feb 7, 2011, at 3:00 PM, Howard Moon wrote:
>> I know how to get an NSBundle for an Application, but how do I get an AudioUnit's bundle? If I use the same code as in an app, [NSBundle mainBundle], then I get the bundle for the host application, not my AudioUnit.
>>
>> I'm modifying the uiViewForAudioUnit function so that the first time it is called (which I can tell because a certain member is not yet initialized), I want to load the contents of a file in the Resources folder of my bundle. But using mainBundle gives me the host (Logic) bundle location, not my AU's bundle. I've been looking for an hour now, and can't find how to get the bundle for the passed-in AudioUnit (inAU) parameter.
>>
>
> I've figured out a way to get the bundle, but my Objective-C isn't too good yet, obviously. When I do the following, I get the contents of the file loaded into my member string, but I'm getting access violations, especially if I instantiate a second instance of the AudioUnit. Here's the code I added to my uiViewForAudioUnit:
>
> if (!xmlViewHierarchy)
> {
> NSBundle* auBundle = [NSBundle bundleForClass:[MyAUCocoaViewFactory self]];
> NSString* pathToXML= [[auBundle resourcePath] stringByAppendingPathComponent:@"MyTestData.xml"];
> xmlViewHierarchy = [NSString stringWithContentsOfFile:pathToXML encoding:NSUTF8StringEncoding error:NULL];
> }
>
> I'm setting xmlViewHierarchy in an override of init for my view factory (just after calling super init), and releasing it in dealloc (just before calling super dealloc).
>
> I'm missing something basic, but I'm not sure what it is. Do I need to release the pathToXML or auBundle variables here? Anything else?
>
I changed "self" to "class" in the call to bundleForClass:, which also works (and is apparently what is *really* supposed to be passed there), and also added [pathToXML release]; at the end of that block, but I still get EXC_BAD_ACCESS at some point after this code runs.
Any ideas?
Thanks,
Howard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden