Re: C functions and instance variables
Re: C functions and instance variables
- Subject: Re: C functions and instance variables
- From: "Hamish Allan" <email@hidden>
- Date: Fri, 28 Mar 2008 09:28:46 +0000
On Fri, Mar 28, 2008 at 9:14 AM, Trygve Inda <email@hidden> wrote:
> I have a Cocoa object with .m and .h files and need to include in this a
> series of about 30 C functions which all all in their own .c file. Is it
> possible to give functions in the .c file access to the .m files instance
> variables?
No, but you can rename the file.c as file.m, pass a pointer to self
from your Obj-C method to your C function, and use the ivars' Obj-C
getters/setters within your C function.
> How can I do this without rewriting the .c functions as Obj-C?
You don't need to rewrite anything, as you can mix C and Obj-C freely
in a .m file.
> Also, is there a way to use two .m files for one object so that all my code
> doesn't have to be in one file? Can I just #import one .m file into the
> other?
You can use categories:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_1.html
Hamish
_______________________________________________
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