Re: Returning a string value from a c function to a Objective-C class method. Is there an approved approach?
Re: Returning a string value from a c function to a Objective-C class method. Is there an approved approach?
- Subject: Re: Returning a string value from a c function to a Objective-C class method. Is there an approved approach?
- From: Steve Sisak <email@hidden>
- Date: Fri, 04 Mar 2016 19:25:24 -0500
> On Mar 4, 2016, at 4:14 PM, Alex Zavatone <email@hidden> wrote:
>
> I'm working with PJSIP and PJ's docs clearly state, "we are going to crater unless you do everything SIP related on the main thread."
Ugh. And of course, doing networking on the main thread is a no-no according to Apple.
——
First, it might be worth seeing if you can have a PJSIP queue (preferred) or thread, which isn’t the main thread — if there are no locks in PJSIP, but it doesn’t use thread-local storage, then it only need to be protected from reentrancy — then you can just make all your PJSIP calls from blocks wrapped in dispatch_async on the PJSIP queue. Thread-local storage complicates this. But I digress…
——
How is the storage of your C strings allocated? malloc()?
What I’d do is use CFString (from CoreFoundation, which is a C API and does all the right callback stuff) and take advantage of the fact the CFString is toll-free bridged to NSString.
Now your C code returns a CFString (C API) which can be cast to NSString as soon at it hits Obj-C code.
HTH,
-Steve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden