这应该做的伎俩:
这里是我的功能,设置标签的文本,它看起来像这样
-(void)seeValue
{
appdelegate = (stackoverflowQueriesAppDelegate*)[[UIApplication sharedApplication]delegate];
lbl.text = [NSString stringWithFormat:@"%.f",appdelegate.f];
}
我为我的标签LBL的文本指定一个浮点值,这里是目前的代码视图我的appdelegate文件
内
@interface stackoverflowQueriesAppDelegate : NSObject {
float f;
}
@property (nonatomic,assign) float f;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end
,这里是为了我的appdelegate.m文件
@implementation stackoverflowQueriesAppDelegate
@synthesize window=_window,f;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
f= 225.32;
myview *obj = [[myview alloc]init];
[self.window addSubview:obj.view];
[self.window makeKeyAndVisible];
return YES;
}
希望这有助于
您的格式可能不正确,即'nil'。尝试把它放在'NSLog()'中。 – 2011-05-27 23:52:00
什么类是'appDelegate.times'的一个实例? – 2011-05-27 23:52:16
'次'是一个浮点数吗?我注意到你正在使用两个不同的'NSString'占位符。 – raidfive 2011-05-27 23:52:46