我已經寫了溫度轉換爲iPhone代碼,但它無法正常工作,並沒有給出任何錯誤,請幫助溫度轉換不給輸出
接口部分
#import <UIKit/UIKit.h>
float n ;
float k;
@interface farh_celcius_conv_AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UILabel *display;
IBOutlet UITextField *farhenite;
IBOutlet UIButton *convert;
}
-(IBAction) convert;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UILabel *display;
@property (nonatomic, retain) IBOutlet UITextField *farhenite;
@property (nonatomic, retain) IBOutlet UIButton *convert;
@end
實現部分
#import "farh_celcius_conv_AppDelegate.h"
@implementation farh_celcius_conv_AppDelegate
@synthesize window,display,farhenite;
-(IBAction) convert {
NSString *str = [NSString text];
float n = [str floatValue];
k = (n - 32)*(5/9);
[display setText:[NSString stringWithFormat:@"%f",k]];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window makeKeyAndVisible];
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
請格式化你的代碼部分,以便它們正確顯示! – jv42 2011-05-11 09:43:20
什麼是我在[NSString我],我沒有申報任何地方。 – 2011-05-11 09:45:22
NSString * str = [NSString i];什麼是'我'? – PgmFreek 2011-05-11 09:46:58