Re: Building a C library Objective-C wrapper framework
Re: Building a C library Objective-C wrapper framework
- Subject: Re: Building a C library Objective-C wrapper framework
- From: Jens Alfke <email@hidden>
- Date: Sun, 20 Jul 2008 17:14:03 -0700
On 19 Jul '08, at 9:12 AM, Uli Kusterer wrote:
Instance variables are easy: You can declare a pointer to a struct
without needing to declare the struct itself, so put all your ivars
into a struct:
A related tip is that you can usually declare pointers to custom
structs from libraries without having to include the header. The
tricky bit is that usually one refers to such a struct by a typedef;
but to work without the header, you have to use the original struct
declaration itself.
For example, if foolib.h declares a struct like this:
struct FooContext {
...
};
typedef struct FooContext* FooRef;
Then in your header you can declare a FooRef instance variable without
having to #include <foolib.h>, by using the FooContext:
@interface MyFooWrapper {
struct FooContext *_foo;
}
In your implemenation you just use _foo as a FooRef.
This works because the compiler understands what "struct FooContext*"
means without having to have seen a declaration of the struct, and
because "struct FooContext*" is equivalent to "FooRef".
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden