में मैं अपने व्यू कंट्रोलर में C++ क्लास को कॉल करना चाहता हूं। Hello.h"उदाहरण संदेश के लिए रिसीवर प्रकार एक आगे की घोषणा है" xcode 4.6
#import <Foundation/Foundation.h>
@interface Hello : NSObject{
class NewHello{
private:int greeting_text;
public:
NewHello(){
greeting_text=5;
}
void say_hello(){
printf("Greeting_Text = %d",greeting_text);
}
};
NewHello *hello;
}
-(void)sayHellooooo;
@end
Hello.mm
#import "Hello.h"
@implementation Hello
-(void)sayHellooooo{
hello = new NewHello();
hello->say_hello();
}
@end
ViewController.h
#import <UIKit/UIKit.h>
//#include "Hello.h"
@class Hello;
@interface ViewController : UIViewController{
}
@end
ViewController.m
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"dddddddd");
Hello *aa = [[Hello alloc]init];
[aa sayHellooooo];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
यह: तो मैं इस तरह एक वर्ग बनाने पी में ठीक काम करता है roject: http://files.cnblogs.com/cpcpc/Objective-C%E8%B0%83%E7%94%A8C.rar
लेकिन जब मैं अपनी परियोजना में कोड कॉपी करता हूं, तो ऐसा लगता है कि "उदाहरण संदेश के लिए रिसीवर प्रकार एक आगे की घोषणा है" त्रुटि।
यदि मैं "@class हैलो" बदलता हूं; #import "Hello.h" पर, ऐसा लगता है कि "कक्षा न्यूहेल्लो" में "Unkwon टाइप क्लास, क्या क्लास" त्रुटि है।
मैं xcode 4.6 का उपयोग करता हूं। क्या कोई मेरी मदद कर सकता है? धन्यवाद!
यह काम करता है! बहुत बहुत धन्यवाद! – Willen
धन्यवाद यह बहुत मदद की :) –