我忙於在Xcode中做測試程序。到目前爲止,我在main.m中有這個代碼。我根本沒有得到任何錯誤,但輸出沒有發生,例如打印方法中的NSLog。沒有錯誤,但NSLog不輸出
可能是什麼問題?我知道我必須失去一些明顯的東西。
#import <UIKit/UIKit.h>
#import "JTAppDelegate.h"
@interface Fraction: NSObject
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
@end
@implementation Fraction
{
int numerator;
int denominator;
}
-(void) print
{
NSLog (@"%i/%i", numerator, denominator);
}
-(void) setNumerator:(int)n
{
numerator = n;
}
-(void) setDenominator:(int)d
{
denominator = d;
}
@end
int main (int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([JTAppDelegate class]));
// Create an instance of Fraction and initialise it
Fraction *myFraction = [[Fraction alloc] init];
//Set Fraction to 1/3
[myFraction setNumerator: 1];
[myFraction setDenominator: 3];
//Display the fraction using the print method
[myFraction print];
}
}
嗯......控制從返回的回報UIApplicationMa – Guru 2013-02-27 10:54:00
看看[這裏](http://stackoverflow.com/questions/6279551/nslog-stopped-working -in-xcode)相關問題 – Groot 2013-02-27 10:54:39
你在哪裏調用'print'? – Larme 2013-02-27 10:54:54