f



[Objective-C++] Objective-C wrappers around C++ classes and KVC

Suppose I have a C++ class named Bar, and an Objective-C wrapper for it
called BarWrapper that I use so that BarWrapper has a few KVC-compliant
methods (essentially, Bar is the model of something I need to link to
an NSArrayController through BarWrapper).  Now inside Bar I have a
std::vector<Bar*> object, and of course I need to make indexed
accessors of the BarWrapper* type.

Now, I have two issues, both with the NSArrayController that the
BarWrappers are connected to:

- the first (and the easier one) is deleting BarWrappers: If I remove a
BarWrapper from the master list, I need to remove all the other
BarWrappers that refer to the same Bar (then dispose of the Bar, but
that's another matter).  Should I subclass NSArrayController for that
functionality?
- the second issue (and maybe connected to the first) is adding them:
Bar is non-POD, so BarWrapper contains a pointer to a Bar object. 
Thus, to make a Bar I need to use new.  However, now the issue is that
I still need the indexed accessors to return a BarWrapper*.  Do I
simply look through the NSArrayController's content array and return
the appropriate BarWrapper* within, or do I make a second BarWrapper*
that points to the same Bar object?

-- 
I am only a mirage.
0
kelvSYC
8/25/2005 4:40:40 PM
comp.sys.mac.programmer.help 4653 articles. 2 followers. Post Follow

0 Replies
1099 Views

Similar Articles

[PageSpeed] 4

Reply:

Similar Artilces:

How to declare a C or C++ function in a Objective C class
Hi, I need to write few functions, which I need to pass to a method in Objective C class using the pointers to those functions. These functions use the instance variable of the class. Hence they must have access to the variables. I want to write functions in C or C++ because they are crucial to the efficiency of my code and I don't want to use selectors way of passing methods for the same reasons. Then where do I include the function declations and implementations in ..h and .mm files of the class. Ankush In article <1150755755.068251.207990@h76g2000cwa.googlegroups.com>, ankushiitk@gmail.com wrote: > Hi, > I need to write few functions, which I need to pass to a method in > Objective C class using the pointers to those functions. These > functions use the instance variable of the class. Hence they must have > access to the variables. > I want to write functions in C or C++ because they are crucial to the > efficiency of my code and I don't want to use selectors way of passing > methods for the same reasons. > Then where do I include the function declations and implementations in > .h and .mm files of the class. > Ankush Consider adding a userData parameter to your fast C++ functions. Define a struct that has a pointer to your Objective C object instance members. Add an initBridge Objective-C method that initializes the struct with pointers to objective-C members. Now, your fast function ...

Objectives on C and C++
hello, Can ne one tell me the sites where i can solve/download objective questions on C and C++? I want them for preparing for interviews. rudranee@gmail.com wrote: > hello, > Can ne one tell me the sites where i can solve/download objective > questions on C and C++? > I want them for preparing for interviews. If you are looking for a serious job, concentrate on proper writing. 'i' should be capitalized, and silly abbreviations like 'ne' make you look less than professional. ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http:/...

Better C/C++ Than C/C++?
I am looking for a good systems programming language that can be used instead of C/C++. My qualifications for the language are: * mature compiler(s) that produce native-code binaries (for Windows) * open source - preferable, but not 100% necessary Thanks, Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) Ocaml, D, cyclone, Eiffel, Beta > * open source - preferable, but not 100% necessary what's wrong with using C? Friedrich > what's wrong with using C? Too low level, no built-in garbage collection. -- Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: >> what's wrong with using C? > > Too low level, Well the Smalltalk people say, have a small language and a big library. I assume C's library status beyond that of Smalltalk. > no built-in garbage collection. Use the Boehm Weisser GC. Friedrich "Kevin Albrecht" <kevin@albrecht.net> wrote in message news:<2TiYb.237892$rj7.1641209@twister.tampabay.rr.com>... > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) > ...

Embedding an Objective-C object in a C structure
Yup, i have a quite perver problem : i would like to embed an Objective-C object within a C structure. The reason is the following: i have an old code base that use a kind of 'object oriented' style in C (stuff quite commons in the 80s and 90s), where an 'object', a kind of plugin for the application, is defined in C by extending a struct, like in: struct { struct basic_object obj; ... new fields .. } I would like to migrate the code base toward Objective-C, but keeping compatibility with the existing stuff. I can of course install a second plugin defin...

C++ objects that act like Java/C# objects.
I've had an idea kicking around in my head regarding how to create a library of classes (templates?) that provide the same kind of functionality as do Java classes which all derive from the UBC Object. There is no UBC in C++, nor will there ever be one (well, there actually /is/ a UBC in C++, but it is a pure abstraction). One feature of user defined Java classes is that they all have a member derived from the java.lang.Class object. The Class member object is part of what provides introspection. I haven't looked at this in a couple years, so the details are a bit hazy for me. Another aspect of Java classes is that all their member functions (AKA methods) are actually objects (or at least can be represented as objects). A Method object holds information such as the identifier and an array of Class objects representing the parameter list. You can query a Java object at runtime to determine its interface. You can also get its superclass (AKA baseclass), etc. C++ has objects that act like functions. Could a C++ class be created with public function objects derived from a class called Function, and providing the same functionality as the Java Method objects? I don't know exactly how useful this would be, but it seems worth exploring in view of the fact that both Java and C# have something like this as a builtin language feature. One place where this is useful is actually at design time. Classes are instantiated by the IDE, and queried for their contents. ...

Sending message to Objective-C object from C file
Hi everyone, I am an experienced programmer but quite new in Mac OS programming. I am developing a Cocoa application. I have an old C library files which I want to reuse in this application. Part of that C library file plays an audio file using another Audio library file. I want to replace functionality of that Audio library file with QuickTime. So I have created a Controller Objective-C object that includes QTMovieViewer and can use that to play an audio file. Now my question is how to send message to that Objective-C object from a C file in my old library. Thanks in advance Luca. In article <f8f4sk$dgm$1@news-01.bur.connect.com.au>, "Luca_a" <nojunk@nojunk.com> wrote: > Hi everyone, > > I am an experienced programmer but quite new in Mac OS programming. I am > developing a Cocoa application. I have an old C library files which I want > to reuse in this application. Part of that C library file plays an audio > file using another Audio library file. I want to replace functionality of > that Audio library file with QuickTime. > > So I have created a Controller Objective-C object that includes > QTMovieViewer and can use that to play an audio file. Now my question is how > to send message to that Objective-C object from a C file in my old library. I would say that in general if you find yourself needing to do that, the best place to start is to rethink your design. ...

c function wrappers in C++ Object DLL
I have an extensive codebase written in C++ that I would like to be able to= access in Labview. In order to access my c++ code I have started DLL proj= ects in Visual Studio, and have created an export file per project which si= mply wraps the C++ class into a bunch of function calls.<br><br>One example= is a USB Driver I have written. I have created a new file named USBExport= s.cpp. Within this file are simply wrapper functions ( with extern "C" to= avoid the name mangling problem ) that take a uint32 as a reference to a C= ++ object, and then take the rest of th...

How To Accessing C++ Class objects in C : getting error fatal error C1189: #error : "eh.h is only for C++!"
hi , i am Getting this Error fatal error C1189: #error : "eh.h is only for C++!" my Problem is i am Having C++ librabry and Appropriate .h file i want to Access Them is .c File Files..... to Be More Specific i am Creating a C++ Object in a C file... this Giving me the error!!! :( can Any Body Please Help me How to Access the C++ object in C file... Thanks In Advance :) Hi, > How to Access the C++ object in C file... Please have a look at the following page http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html Regards On Jan 7, 11:17=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com> wrote: > hi , > i am Getting this Error > fatal error C1189: #error : "eh.h is only for C++!" > my Problem is i am Having C++ librabry and Appropriate .h file > i want to Access Them is .c File Files..... > to Be More Specific i am Creating a C++ Object in a C file... > this Giving me the error!!! :( > > can Any Body Please Help me > > How to Access the C++ object in C file... > Thanks In Advance :) In general, you can't. You can provide a procedural interface instead, and declare it in a header file like this: #ifdef __cplusplus extern "C" { #endif void some_function(int, char*, double); // or whatever #ifdef __cplusplus } #endif This can then be included from both C and C++. On Jan 7, 4:32=A0pm, tragomaskhalos <dave.du.verg...@logicacmg.com> wrote: > On Jan 7, 11:17=A0am, "...

C/C++ in matlab and matlab in C/C++ ?
Is it possible to read C/C++ code in matlab and the other way around too? Hi, as long as C or C++ are written in text files you can edit them in the matlab editor. To see the special character of C or C++ coding language, in the editor go to menus: file>preferences>Edito/Debugger>language and on popup "Language" select "C/C++". This does not allow you to run the C/C++ code, just to view it i nicer way... regards, chris saneman <asdfsdf@asd.com> wrote in message <frl846 $f8i$2@news.net.uni-c.dk>... > Is it possible to read C/C...

C/C++ in MATALB or MATLAB in C/C++?
Hi I've been asking on the net how to use MEX properly so that I can use C/C++ in MATLAB, but information is not forthcoming. There seems to be a lot on using MATLAB in C/C++ but not the other way around. I understand Mathworks is trying very hard to sell the Matlab Compiler, but even so, why is it SO hard to get information about MEX? Or is it that I've missed something very fundamental, meaning that I'm struggling over something that is actually quite easy? Any thoughts and info would be great. Thanks BullDog BullDog wrote: > Hi > > I've been asking on the net ...

[Urgent]: How To Accessing C++ Class objects in C : getting error fatal error C1189: #error : "eh.h is only for C++!"
hi , i am Getting this Error fatal error C1189: #error : "eh.h is only for C++!" my Problem is i am Having C++ librabry and Appropriate .h file i want to Access Them is .c File Files..... to Be More Specific i am Creating a C++ Object in a C file... this Giving me the error!!! :( can Any Body Please Help me How to Access the C++ object in C file... Thanks In Advance :) "sachinv1821@gmail.com" <sachinv1821@gmail.com> writes: > How to Access the C++ object in C file... > Thanks In Advance :) You'd be better off asking in comp.lang.c++. I know this sounds...

Objective C -> C
1) Is there a good book for C programmers to be able to read Objective C code examples? I just want to know the basics for translation. 2) I'm trying to translate some code to C and am scratching my head a few places. Here are the mysterious lines to me (not the entire function): before the function: - (IBAction) Install:(id)sender inside the function: NSBundle*myBundle = [NSBundle mainBundle]; NSString*path = [myBundle pathForResource:@"theDataFork" ofType:@"rsrc"]; NSURL *urlRef = [[NSURL alloc] initFileURLWithPath:path]; I have no idea what the line before the function means. My guess on the first line inside the function: CFBundleRef myBundle = CFBundleGetMainBundle(); for the next two, combine to one call: CFURLRef urlRef = CFBundleCopyResourceURL(myBundle,CFSTR("theDataFork"),CFSTR("rsrc"),NULL); though perhaps a CFURLCreate... function is correct, I don't know, but that gets into CFAllocators. Thanks for any insight. -- Mac program, CW8 in C In <BB7A8FFF.ADE%brucecoughlin@nyc.rr.com> Bruce Coughlin wrote: > 1) Is there a good book for C programmers to be able to read Objective > C code examples? An excellent book is on your computer. In fact, the book on Objective-C on your computer is one of the best computer books I've ever read, on any subject. > I just want to know the basics for translation There is no "translation". Ob...

wrapping c++ or objective-c++
I'm working on an app that is built off a medium-sized (~100 source files or so) c++ framework. I have to interact with some of Apple's Cocoa frameworks so Objective-C is the natural language choice for the app. The question I'm dealing with now is whether I should write ObjC wrappers for the classes in the framework or simply use Objective-C++. I've already hacked together a little demo app using Objective-C++, but I fear that dealing with multiple memory management patterns is going to cause me headaches as my app gets larger. On the other hand, writing wrappers f...

converting objective-c to c
Is there a way to convert objective-c to c using mac os-x 10.4.2 and all the latest compilers? (gcc 4.0, xcode 2) If so, how? Santa Claus <santa@northpole.com> wrote: > Is there a way to convert objective-c to c using mac os-x 10.4.2 and all > the latest compilers? (gcc 4.0, xcode 2) If so, how? The short answer: no. The long answer: the only ObjC-to-C translator that's still in existence is POC. Gcc's ObjC compiler is a direct compiler, with no intermediate C code. POC's dialect of ObjC is significantly different from gcc's, and there is no hop...

Read again about my objection about C++ and C
Hello, I have just took a look to operator overloading in FreePascal and Delphi, so look at how powerful it is, here is an example: === program OperatorsTest; {$APPTYPE CONSOLE} uses SysUtils; type TIntValue = record private FValue: Integer; public class operator Add(const a, b: TIntValue): TIntValue; class operator Implicit(const a: Integer): TIntValue; class operator Implicit(const a: TIntValue): Integer; property Value: Integer read FValue; end; { TIntValue } class operator TIntValue.Add(const a, b: TIntValue): TIntValue; begin Result.FValue := a.FValue + b.FValue; end; class operator TIntValue.Implicit(const a: Integer): TIntValue; begin Result.FValue := a; end; class operator TIntValue.Implicit(const a: TIntValue): Integer; begin Result := a.FValue; end; var Int: TIntValue; begin Int := 5; Int := Int + 10; WriteLn(IntToStr(Int)); end. === You can overload the following operators in both FreePascal and Delphi, read here: http://docwiki.embarcadero.com/RADStudio/Seattle/en/Operator_Overloading_(Delphi) In ADA when you define two types like this: type length is new float; type weight is new float; You can not assign type length to type weight, this strong typing of Ada you can do it easily with object oriented programming in FreePascal and Delphi and C++. So what remains about C and C++ is that...

C++ templates in Objective-C
Hallo, I have a problem using C++ und Objective-C in a mixed-mode OS-X application. (gcc version: gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1640), Apple Dev. System) The function bar(...) works fine! The template function foo(...) will not work. It causes a memory problem (EXC_BAD_ACCESS signal). Where is the problem? Source: ->File: test.h #import <Cocoa/Cocoa.h> template<class T> void foo(T *arr) { // printf("Adr: %i\n", arr); printf("foo: ---%s---", [[arr objectAtIndex:0] cString]); [arr addObject:@"Test2"]; printf("%s---\n\n", [[arr objectAtIndex:1] cString]); } void bar(NSMutableArray *arr) { // printf("Adr: %i\n", arr); printf("bar: ---%s---", [[arr objectAtIndex:0] cString]); [arr addObject:@"Test2"]; printf("%s---\n\n", [[arr objectAtIndex:1] cString]); } ->File: test.mm // gcc test.mm -lobjc -framework Cocoa -lstdc++ #import <Cocoa/Cocoa.h> #include <iostream> #include "test.h" int main(void) { NSAutoreleasePool *pool1 = [[NSAutoreleasePool alloc] init]; NSMutableArray *arr = [[NSMutableArray alloc] init]; [arr addObject:@"Test1"]; foo<NSMutableArray>(arr); // Memory error->Program received signal // EXC_BAD_ACCESS, Could not access // me...

C,, C++, Java, C#
I come from C,C++,Java and C#. What can SmallTalk do for me and for what cost? Regarding the Squeak thing, it's interesting though confusing. Is it an IDE? Why are the menus so wacky? "DM McGowan II" <nospam@nospam.net> wrote in message news:PLednX2vnLd11IncRVn-rA@comcast.com... > I come from C,C++,Java and C#. What can SmallTalk do for me ...? Ask not what Smalltalk can do for, but what can you do with Smalltalk. :-) In very few words, it significantly reduces time to market, while enhancig the development experience. This is because: 1. It manages the memory for you, so you don't have to allocate/deallocate all the time (the source of some of the most nasty bugs in C). Java and C# learnt that feature from ST. 2. It has single inheritance. 3. All the development is in a single file, called the image, so you don't have to fish for where did you put that missing class. Yet, you don't have to go through thousands of lines of code to find the method you wrote three months ago. 4. It's the language for which it's easier to work within the Agile methodologies. 5. It's strongly typed without being unnecessarily redundant. 6. It's "wacky" interface releases you from the need to use curlys. 7. It comes with a huge library, so you don't need to reinvent the wheel as much. 8. It's debugger is highly integrated and friendly, so the experience of findin...

C, C++ and C# Forums
Throne Software has opened up C, C++ and C# Forums at: http://www.thronesoftware.com/forum/ Join us! ...

c,c++,obj-c
Of the 3 languages titled in this post is c++ older than obj-c ? Would someone experienced in C be able to dive right into C++ rather than obj-c ? Java is out for me now except applet programming I think I'm going to go with just C and C++. Bill Bill Cunningham wrote: > Of the 3 languages titled in this post is c++ older than obj-c ? Why does that matter? Do you want to use an old language? Try Fortran or LISP. > Would > someone experienced in C be able to dive right into C++ rather than > obj-c ? Not quite dive in, at least not into the OO parts of C++. ...

c++ or c#
hello all experiancesd techies, i am a final yr engg student with knowledge of c++ n java. i want to start windows programing, n hence have to decide whether to choose my language as c++ or c#. please guide me which language would benefit in the long run, if i intend to persue a job in a product development company/( like adobe) after graduation,(not in a consultancy like acenture). also suggest me good books for that. thanx a lot <pravin.chaudhary@gmail.com> wrote in message news:1131971088.291580.42500@g47g2000cwa.googlegroups.com... > i am a final yr engg student with ...

C or C++?
Hi, I am a newbie to programming, and sorry again that I have to ask the C or C++ questions. Is C required before learning C++? And become better in C does it also make you a better C++ programmer? Or that to be a C+ + programmer, it's better not to have any knowledge of C and start a new in the C++ way as some books suggest? weidongtom@gmail.com wrote: > Hi, > > I am a newbie to programming, and sorry again that I have to ask the C > or C++ questions. Is C required before learning C++? No. And become better > in C does it also make you a better C++ programmer? Not n...

More about C and C++
Hello, I have wrote: >I will resume it like this: >On the criterias of "complexity" and "difficulty", the C and C++ >programming languages are more complex and difficult than Object >Pascal for example, so since they are more complex and difficult they >are likely to create something like a darwinian filter who don't let >the weaker humans among us humans to cross or to climb the social >ladder, this is why i think that C and C++ do participate to social >darwinism, this is why i say that C and C++ are bad. Josep...

C++ to C
Are there any open source C++ compilers that will produce C code? I understand the first C++ compilers operated this way. On Mon, 27 Oct 2003 23:07:19 GMT, "Bootstrap Bill" <wrcousert@yahoo.com> wrote in comp.lang.c: > Are there any open source C++ compilers that will produce C code? I > understand the first C++ compilers operated this way. C++ compilers are off-topic in comp.lang.c. -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq "Bootstrap Bill" <wrcousert@yahoo.com> writes: > Are there any open source C++ compilers that will produce C code? I > understand the first C++ compilers operated this way. You might want to have a look at Comeau - it's not open source, but it's cheap, and AFAIK does exactly what you want (www.comeaucomputing.com) HTH & kind regards frank -- Frank Schmitt 4SC AG phone: +49 89 700763-0 e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com in comp.lang.c i read: >"Bootstrap Bill" <wrcousert@yahoo.com> writes: >> Are there any open source C++ compilers that will produce C code? I >> understand the first C++ compilers operated this way. > >You might want to have a look at Comeau - it's not open source, but >it's cheap, and AFAIK does exactly what you want but note ...

C C++
While reading some source code, I saw a variable called "end" of type "time". So I investigated what the type "time" meant and saw that time was a typedef for "Real". So what does "Real" mean? "Real" is a typedef for QL_REAL. So what does "QL_REAL" mean? QL_REAL is type double via the line of code #define QL_REAL double.... "Mallik * G" <gadde.mallik@gmail.com> wrote in message news:7e4a882c-6f46-46eb-aa54-903842fa1b4d@p39g2000prm.googlegroups.com... > While reading some source code, I saw a variable cal...

Web resources about - [Objective-C++] Objective-C wrappers around C++ classes and KVC - comp.sys.mac.programmer.help

Compiler Warnings: Calling the User-Defined Default Constructor from Objective-C++ Code
Interoperating between Objective-C and C++ code requires careful work as constructor calls vary, depending on which compiler you use.

Problems When Linking Objective-C and C++ Code
Interoperating between Objective-C and C/C++ code presents several linker challenges, some of which are addressed in these recipes.

Calling an Objective-C Method from a C++ Class
A simple renaming trick will get rid of all the error messages.

Resources last updated: 3/19/2016 4:38:31 PM