• 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: Encapsulate C struct/toll-free bridging?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Encapsulate C struct/toll-free bridging?


  • Subject: Re: Encapsulate C struct/toll-free bridging?
  • From: Nathan Day <email@hidden>
  • Date: Tue, 09 Mar 2004 17:07:41 +1100

Not sure exatly what your are trying to do, is this what you want

@interface List : NSObject
{
@private
struct C_CList list;
int otherData;
}
- (SInt32)numItems;
...
- (C_CList*)list;
@end

@implementation List

- (SInt32)numItems
{
return list.numItems;
}
...
- (C_CList*)list
{
return &list;
}

@end

On Tuesday, March 09, 2004, at 02:52PM, David Bainbridge <email@hidden> wrote:

>I am passing a C data structure back and forth between Cocoa framework
>and carbon CFM code. Is there an elegant way to encapsulate structs
>such that I can integrate it better with Objective-C/Cocoa? Example
>struct:
>
>struct C_CList {
> SInt32
>numItems;
> SInt32 slots;
> SInt32
>blockSize;
> Handle hItems;
> SInt32
>elementSize;
> UInt8
>lockChanges;
> UInt8
>usingTemporary;
>};
>
>
>I would like this to actually be data members to an objective-c class
>and access the data with methods like -(SInt32)numItems, etc.. I don't
>wish to allocate an object and copy each data member over to it and
>then turn around and copy it back to the struct when it needs to be
>sent back to the CFM code. Currently I am using class methods and
>passing the entire C struct to modify/access the data. It sounds like
>I am looking for something similar to the toll-free bridging that goes
>on between some CF structures and Cocoa objects.. Any suggestions?
>
>Thanks,
>D. Bainbridge
>_______________________________________________
>cocoa-dev mailing list | email@hidden
>Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>Do not post admin requests to the list. They will be ignored.
>
>
>


Nathan Day
email@hidden
http://homepage.mac.com/nathan_day/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: OK, but what do 'attributes' look like?
  • Next by Date: Re: OK, but what do 'attributes' look like?
  • Previous by thread: Re: Encapsulate C struct/toll-free bridging?
  • Next by thread: Re: Encapsulate C struct/toll-free bridging?
  • Index(es):
    • Date
    • Thread