Re: A CFStringRef that throws EXC_BAD_ACCESS
Re: A CFStringRef that throws EXC_BAD_ACCESS
- Subject: Re: A CFStringRef that throws EXC_BAD_ACCESS
- From: Craig Bakalian <email@hidden>
- Date: Thu, 17 Oct 2002 09:04:13 -0400
Thanks for the help Rosyna!
I didn't know I could cast a NSString from a CFStringRef. Is there
further documentation on stuff like this somewhere? And I agree with
you on the code below. But, oddly, it works in certain circumstances.
for if I do this:
MIDIGetStringProperty(dev, kMIDIPropertyName, &pname)
CFStringGetCString(pname, cname, sizeof(cname), 0);
CFRelease(pname);
it works fine, always returning a string value for any midi hardware
with no bad access.
Also, the cmaxtrans not big enough to hold the CFStringRef wasn't what
was happening. Once I did your informative (NSString *) cast, the
pmaxtrans was null.
Craig Bakalian
On Thursday, October 17, 2002, at 07:53 AM, Rosyna wrote:
>
OSStatus TransErr = MIDIObjectGetStringProperty(dev,
>
kMIDIPropertyMaxTransmitChannels, &pmaxtrans);
>
>
if(TransErr != kMIDIUnknownProperty ){
>
>
CFStringGetCString(pmaxtrans, cmaxtrans, sizeof(cmaxtrans (i
>
wrote pmaxtrans before), 0);
>
>
CFRelease(pmaxtrans);
>
>
[self setMaxTransChannels: [NSString stringWithCString:
>
cmaxtrans]];
>
>
>
I am guessing this never gets called as it seems like it would crash
>
immediately. First, you are using CFRelease to release something that
>
you shouldn't (the function you got it from doesn't contain the words
>
Copy or Create) which should crash. Second, you get the C string from
>
the CFString but release the CFString before using the C string which
>
should also probably crash.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.