实例变量发布了吗?

时间:2013-06-06 19:18:23

标签: objective-c exc-bad-access

您好我基本上使用NSTimer制作一个简单的计时器。

我有代码记住开始日期(NSDate),然后重复计时器每秒触发一次以更新界面。我发现计时器正确触发并调用了选择器,但我在第一行得到了一个异常。非常感谢任何帮助。

错过了无关位的代码:

#import <Foundation/Foundation.h>

@interface PPTTimer : NSObject
{
    NSTimer *mainTimer;
    NSDate *startTime;
    NSTimeInterval timerDuration;
    NSTimer *clockTimer;
    NSTimer *safariTimer;
}

- (void)startTimerForHours:(int)hours minutes:(int)mins;
- (void)pauseTimer;
- (void)resumeTimer;
- (void)finishTimer;
- (void)endTimer:(NSTimer *)theTimer;
- (void)updateClockFire:(NSTimer *)theTimer;
- (void)safariCheckFire:(NSTimer *)theTimer;

@property (assign) IBOutlet NSTextField *leftField;
@property (assign) IBOutlet NSTextField *rightField;
@property (assign) IBOutlet NSTextField *leftLabel;
@property (assign) IBOutlet NSTextField *rightLabel;

@end



#import "PPTTimer.h"

@implementation PPTTimer

@synthesize leftField = leftField_;
@synthesize rightField = rightField_;


- (void)startTimerForHours:(int)hours minutes:(int)mins
{
    startTime = [NSDate date];
    timerDuration = 60*(mins+60*hours);
    mainTimer = [NSTimer scheduledTimerWithTimeInterval:timerDuration target:self selector:@selector(endTimer:) userInfo:nil repeats:NO];
    clockTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateClockFire:) userInfo:nil repeats:YES];
    safariTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(safariCheckFire:) userInfo:nil repeats:YES];
}

选择器代码,错误的屏幕截图:

http://i.stack.imgur.com/zkAo4.png

这是AS代码的相关位,请记住PPTTimer有一个蓝色立方体,并且链接到缺失的值......

property parent : class "NSObject"
    --app classes
    property PPTTimer : missing value
    --windows
    property winMain : missing value
    property winTimer : missing value
    --IB objects
    property hourField : missing value
    property minuteField : missing value

    on startTimerButton_(sender)
        winMain's orderOut_(sender)
        winTimer's makeKeyAndOrderFront_(sender)
        PPTTimer's startTimerForHours_minutes_(hourField's intValue(), minuteField's intValue())
    end startTimerButton_

0 个答案:

没有答案