我在 nib 文件中添加了一个类对象。所有连接都已建立。
但是由于某种原因,对象一被创建就被释放。
这是代码:
控制.h:
#import <Foundation/Foundation.h>
@interface control : NSObject
{
IBOutlet UILabel *PlayerScore;
}
-(IBAction) addPoint: sender;
-(void) dealloc;
@end
控制.m:
#import "control.h"
@implementation control
-(IBAction)addPoint: sender {
NSLog(@"Ohhai. Didn't crash."); //Doesn't even make it to this stage.
int i = [PlayerScore.text intValue];
PlayerScore.text=[NSString stringWithFormat: @"%d",++i];
}
-(void) dealloc {
NSLog(@"ZOMGWTF?");
[super dealloc];
}
@end
这是控制台日志:
[会话开始于 2010-06-09 19:47:57 +1000。]
2010-06-09 19:47:58.771 App[91100:207] ZOMGWTF?
在我单击消息 addPoint 的按钮后,它当然会崩溃。
2010-06-09 19:47:59.703 App[91100:207] *** -[control] performSelector:withObject:withObject:]: 消息发送到已释放实例 0x3843d80
有没有人有任何想法?