Re: Wrapping a C function library (as source) in an ObjC class...
Re: Wrapping a C function library (as source) in an ObjC class...
- Subject: Re: Wrapping a C function library (as source) in an ObjC class...
- From: Clark Cox <email@hidden>
- Date: Sun, 28 Mar 2010 09:32:31 -0700
On Sun, Mar 28, 2010 at 9:18 AM, William Squires <email@hidden> wrote:
> ... and other things.
>
> 1) I have a C library (as a .c and .h) file. I want to encapsulate this
> functionality in an ObjC class. When importing header files into my
> implementation file ".m", do I #include them or #import them? How about
> existing library headers (like <string.h>)?
You can do either.
> 2) If my C code uses malloc/free, and my ObjC project has garbage collection
> turned on, what 'gotcha's do I have to watch out for? What if GC is turned
> off (for iPhone)?
The Garbage collector completely ignores memory allocated via malloc.
Regardless of whether or not GC is on, you are still responsible for
free()'ing malloc()'ed memory. You also have to be careful about
putting pointers to objects into any malloc()'ed memory, as the
collector will not count that as an active reference, and the object
may get collected before you might expect it.
--
Clark S. Cox III
email@hidden
_______________________________________________
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