My first question is that if I write a class in C++ using opencv library to detect any object in an image and call that c++ class in objective-C (xcode project) then will this technique work?
and
Second question is that how I can add c/c++ class in my iphone app project and use it in my traditional ViewController Class.
What I have done till now is uder
: Created a TabView Application with one ViewController. : Added a Push Button in that ViewController. : Added a File.c class which is just printing string. : Imported "File.c" in my ViewController.h and ViewController.m class like
MY ViewController.h class
#import <UIkit/UIkit.h>
#import "file.c"
MY ViewController.m class
#import "FirstViewController.h"
#import "File.c"
now on action of the push button I want to call that C class that I have already added in the project. I am hoping to get good and beneficial answers.
Regards
File.c
#ifndef testC_File_c
#define testC_File_c
#include <stdio.h>
void say_hello() {
printf("Hello World!");
}
#endif
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (IBAction) buttonDown:(id)sender;
@end
ViewController.mm
#import "ViewController.h"
#include "File.c"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction) buttonDown:(id)sender
{
say_hello();
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.