#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
int fromValue;
int toValue;
int nombre;
BOOL comptage;
}
@property (weak) IBOutlet NSTextField *champFrom;
@property (weak) IBOutlet NSTextField *champTo;
@property (weak) IBOutlet NSTextField *champAff;
- (IBAction)takeFrom:(id)sender;
- (IBAction)takeTo:(id)sender;
- (IBAction)start:(id)sender;
- (IBAction)stop:(id)sender;
- (void)updateUserInterface;
- (id) init;
@end
#import "AppDelegate.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[self init];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
- (IBAction)takeFrom:(id)sender {
fromValue = [sender intValue];
//[self updateUserInterface];
}
- (IBAction)takeTo:(id)sender {
toValue = [sender intValue];
//[self updateUserInterface];
}
- (IBAction)start:(id)sender {
nombre=fromValue;
[self updateUserInterface];
comptage=true;
if ((fromValue<=toValue)&&(comptage==true)){
while ((nombre<toValue)&&(comptage==true)) {
nombre=nombre+1;
[self updateUserInterface];
}
}
}
- (IBAction)stop:(id)sender {
//nombre=toValue;
comptage=false;
[self updateUserInterface];
}
- (void)updateUserInterface {
[self.champAff setIntValue:nombre];
}
- (id) init{
self = [super init];
if (self) {
fromValue=0;
toValue=0;
nombre=0;
comptage=true;
return self;
}
else
return nil;
}
@end
I may be reading this wrong (I dislike ObjC thoroughly) but it looks like instead of appending the value of "nombre", you're simply setting the value of the textfield to its value which eventually hits 1,000. Instead of setting the value to whatever nombre is set as, append the value of nombre to the value of the textfield.