Archive for iPhone

iPhone objective-c and c++

if you want to use c++ files in your iphone app do this:

  1. rename the FILE.m in FILE.mm
  2. import the .cpp class

Sample

#import "Foo.cpp"
- (void)aFunction:()
{    
 
 Foo foo = *(new Foo(123));
 NSString *objcString =
[NSString stringWithUTF8String:foo.testStr.c_str()];
 NSLog(@"string test: %@", objcString);
 NSLog(@"foo id start: %i", foo.myId);
 foo.setId(30303);
 NSLog(@"foo id: %i", foo.myId);
}

foo class

#include <string>
 
class Foo
{
 public : int myId;
 public : std::string testStr;
 
 public : Foo(int startVal)
 {
 testStr = "Hallo Welt21212! äöü ß";
 myId = startVal;
 };
 
 public : void setId(int newId)
 {
 myId = newId;
 };
 
 public : void test()
 {
 
 }
};

iPhone holo toy

via