0

私の最初の質問は、opencv ライブラリを使用して C++ でクラスを作成し、画像内のオブジェクトを検出し、その c++ クラスを object-C (xcode プロジェクト) で呼び出す場合、この手法は機能するかということです。

2 番目の質問は、 iPhone アプリ プロジェクトにc/c++クラスを追加し、それを従来の ViewController クラスで使用する方法です。

今までやってきたのはuder

: 1 つの ViewController で TabView アプリケーションを作成しました。: その ViewController にプッシュ ボタンを追加しました。: 文字列を出力するだけの File.c クラスを追加しました。: ViewController.h および ViewController.m クラスに「File.c」をインポートしました

私の ViewController.h クラス

#import <UIkit/UIkit.h>
#import "file.c"

私の ViewController.m クラス

#import "FirstViewController.h"
#import "File.c"

プッシュボタンのアクションで、プロジェクトに既に追加したCクラスを呼び出したいと思います。有益で有益な回答が得られることを願っています。

よろしく

4

1 に答える 1

0

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
于 2012-09-28T05:39:09.973 に答える