iOS 我把这段代码放进 xcode 之后,为什么显示Unknown class ViewController in Interface Builder fil

#import <Foundation/Foundation.h>
@interface Person : NSObject
{
@public
int age;
double height;
}
- (void)print;
@end

void test1(int newAge, double newHeight);
void test2(Person *newP);
void test3(Person *newP);
void test4(Person *newP);

int main()
{
Person *p = [Person new];
p->age = 10;
p->height = 1.5f;

test1(p->age, p->height);
[p print];

test2(p);
[p print];

test3(p);
[p print];

test4(p);
[p print];

return 0;
}

@implementation Person
- (void)print
{
NSLog(@"年龄=%d,身高=%f", age, height);
}
@end

void test1(int newAge, double newHeight)
{
newAge = 10;
newHeight = 1.6;
}

void test2(Person *newP)
{
newP->age = 20;
newP->height = 1.7;
}

void test3(Person *newP)
{
Person *p2 = [Person new];
p2->age = 40;
p2->height = 1.8;
newP = p2;

newP->age = 30;
}

void test4(Person *newP)
{
Person *p2 = newP;
p2->age = 50;
p2->height = 1.9;
newP->age = 60;
}
最新回答
纸墨清香

2024-06-25 06:13:54

ViewController
这个文件是建项目默认生成的,共三个文件
ViewController.h
ViewController.m
ViewController.xib
我估计你是删掉了
ViewController.h
ViewController.m
但是没有删ViewController.xib
所以,在ViewController.xib里面,有一个属性是Class,这个Class应该默认就是
ViewController,但是你删掉了ViewController.h
追问
我在 os 操作中的main.m 文件中复制进去就可以正常使用,我没有删