0

Is it possible to use bindings (NSArrayController etc) if you have to have a c++ in the model, ie all files in the model have .mm extension.

Have built a small test program in pure Objective-C, which works OK, but when I try to build a program with c++ libraries it seems that nothing happen, it compiles and starts, but nothing happens with tableviews etc.

One should perhaps not ask if it is possible to use bindings to c++, rather if they are worth it for a objective-c/cocoa newbie.

Thanks

  • What do you expect to "happen with tableviews"? You can not mix C++ and Objective-C classes, but beside of this, there are no problems mixing the code, i.e. use C++ inside (and outside) ObjC code. – Matthias Jan 13 '13 at 22:35

1 Answers1

0

You're right, I replaced this c + + code

/ / Get the attribute 
for (oscar :: ODStruct :: iterator iter = data.begin (); ites! = data.end (); iter + +) 
{ 
   mem = iter-> second; 
   if (mem.get (s_vals)) 
      for (auto i = s_vals.begin (); in! = s_vals.end (); i + +) 
         [_owner SetValue: [NSString string with format: @ "% s", i-> c_str ()] 
                  forKey: [NSString string with format: @ "% s", iter-> first.c_str ()]]; 
   else if (mem.get (i_vals)) 
       for (auto i = i_vals.begin (); in! = i_vals.end (); i + +) 
          [_owner SetValue: [NSString string with format: @ "% d", * i] 
                  forKey: [NSString string with format: @ "_% s", iter-> first.c_str ()]]; 
   else if (mem.get (f_vals)) 
       for (auto i = f_vals.begin (); in! = f_vals.end (); i + +) 
          [_owner SetValue: [NSString string with format: @ "% f", * i] 
                  forKey: [NSString string with format: @ "_% s", iter-> first.c_str ()]]; 
   else if (mem.get (d_vals)) 
       for (auto i = d_vals.begin (); in! = d_vals.end (); i + +) 
            [_owner SetValue: [NSString string with format: @ "% lf", * i] 
                  forKey: [NSString string with format: @ "_% s", iter-> first.c_str ()]]; 
   else 
       std :: cout << "Do not find for" << iter-> first.c_str () << std :: endl; 

}

with the following obj-c Code

_owner.name = @ "test" 
_owner.type = @ "test1" 
_owner.unit = @ "test2" 

Then it works! Have left another C + + kode in class, so I've probably missed something with "setValue: forKey: '