超级简单的程序不起作用

nic*_*ude 3 macos xcode objective-c

我正在编写"在客观c 2.0中编程"一书,我不明白为什么这个程序不起作用.基本上我需要建立一个程序,将华氏温度值转换为celcius值.

我想,只是解决这个问题很简单没有对象,只需使用一条直线程序方法,任何办法,我遇到的问题是,该变量的值我定义代表华氏或摄氏值都上来了一种随机的.

这是我的代码:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    float  fahrenheit;
    float  celciusConverted;
    fahrenheit = 27.0;
    celciusConverted = ( fahrenheit - 32 ) / 1.8 ;
    NSLog(@"%f degrees fahrenheit is equal to %f degrees celcius") , fahrenheit, celciusConverted;
    [pool drain];
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

sig*_*ice 5

NSLog语句中的右括号是错误的.应该就在之前;

你拥有的是什么

NSLog(@"... %f %f ..."), arg1, arg2;
Run Code Online (Sandbox Code Playgroud)

编译器似乎不够聪明,看不到任何一个%f都有相应的参数,这是变量函数的常见缺陷NSLog().在右括号之后,逗号运算符启动,表达式arg1和arg2什么都不做.