很抱歉这个简单的问题,但我有一个练习,我必须编写一个Objective-C控制台应用程序,它正方形浮动,并显示在控制台中产生浮动,但我不明白如何写它,可以someong请告诉我如何编写代码以便我理解?
我是对Objective C的开始,所以感谢您的耐心等待! :)
答案 0 :(得分:3)
我没有在iPhone上看到控制台应用程序的用途,但是你去了:
创建一个新项目并从以下内容编辑main.m:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
将其更改为:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
float number = 3.14;
float square = powf(number, 2.0);
NSLog("%f^2=%f", number, square);
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}