• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Building a C library Objective-C wrapper framework
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Building a C library Objective-C wrapper framework (From: Sebastian Nowicki <email@hidden>)
 >Re: Building a C library Objective-C wrapper framework (From: Jens Alfke <email@hidden>)
 >Re: Building a C library Objective-C wrapper framework (From: Sebastian Nowicki <email@hidden>)
 >Re: Building a C library Objective-C wrapper framework (From: Sebastian Nowicki <email@hidden>)
 >Re: Building a C library Objective-C wrapper framework (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Problem compiling first Cocoa app in Xcode 3.1
  • Next by Date: Re: Problem compiling first Cocoa app in Xcode 3.1
  • Previous by thread: Re: Building a C library Objective-C wrapper framework
  • Next by thread: Re: Building a C library Objective-C wrapper framework
  • Index(es):
    • Date
    • Thread