Sheets(Chapter 25 of Cocoa Programming for Mac OS X)
1 //2 //AppController.m
3 //TypingTutor
4 //
5 //Created by b1mobile on 3/3/11.
6 //Copyright 2011 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "AppController.h"
10 #import "BigLetterView.h"
11
12 #define MAX_COUNT (100)
13 //#define COUNT_STEP (5)
14
15 @implementation AppController
16
17 - (id)init
18 {
19 ;
20
21 letters = [ initWithObjects:@"a", @"s", @"d", @"f", @"j", @"k", @"l", @";", nil];
22 srandom(time(NULL));
23 stepSize = 5;
24 return self;
25 }
26
27 - (void)awakeFromNib
28 {
29 ;
30 }
31
32 - (void)resetCount
33 {
34 ;
35 count = 0;
36 ;
37 }
38
39 - (void)incrementCount
40 {
41 ;
42 count = count + stepSize;
43 if (count > MAX_COUNT)
44 {
45 count = MAX_COUNT;
46 }
47 ;
48 }
49
50 - (void)showAnotherLetter
51 {
52 int x = lastIndex;
53 while (x == lastIndex)
54 {
55 x = random() % ;
56 }
57 lastIndex = x;
58 ];
59
60 ;
61 }
62
63 - (IBAction)stopGo:(id)sender
64 {
65 if (timer == nil)
66 {
67 NSLog(@"Starting");
68
69 timer = [ retain];
70 }
71 else
72 {
73 NSLog(@"Stopping");
74 ;
75 ;
76 timer = nil;
77 }
78 }
79
80 - (void)checkThem:(NSTimer *)aTimer
81 {
82 if([ isEqual:])
83 {
84 ;
85 }
86 if (count == MAX_COUNT)
87 {
88 NSBeep();
89 ;
90 }
91 else
92 {
93 ;
94 }
95 }
96
97 - (IBAction)showSpeedSheet:(id)sender
98 {
99 modalDelegate:nil didEndSelector:NULL contextInfo:NULL];
100 }
101
102 - (IBAction)endSpeedSheet:(id)sender
103 {
104 ;
105 ;
106 }
107
108 @end
页:
[1]