Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Problem Dev Cocoa textField
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="nico.v.44" data-source="post: 1664705" data-attributes="member: 356103"><p>Thanks,</p><p>My code is :</p><p></p><p>AppDelegate.h</p><p>[CODE]</p><p>#import <Cocoa/Cocoa.h></p><p></p><p>@interface AppDelegate : NSObject <NSApplicationDelegate></p><p></p><p>{</p><p> int fromValue;</p><p> int toValue;</p><p> int nombre;</p><p> BOOL comptage;</p><p>}</p><p></p><p>@property (weak) IBOutlet NSTextField *champFrom;</p><p>@property (weak) IBOutlet NSTextField *champTo;</p><p>@property (weak) IBOutlet NSTextField *champAff;</p><p></p><p>- (IBAction)takeFrom:(id)sender;</p><p>- (IBAction)takeTo:(id)sender;</p><p></p><p>- (IBAction)start:(id)sender;</p><p>- (IBAction)stop:(id)sender;</p><p></p><p>- (void)updateUserInterface;</p><p>- (id) init;</p><p></p><p>@end</p><p>[/CODE]</p><p></p><p></p><p></p><p>AppDelegate.m</p><p>[CODE]</p><p>#import "AppDelegate.h"</p><p></p><p>@interface AppDelegate ()</p><p></p><p>@property (weak) IBOutlet NSWindow *window;</p><p></p><p>@end</p><p></p><p>@implementation AppDelegate</p><p></p><p>- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {</p><p> // Insert code here to initialize your application</p><p> [self init];</p><p>}</p><p>- (void)applicationWillTerminate:(NSNotification *)aNotification {</p><p> // Insert code here to tear down your application</p><p>}</p><p></p><p>- (IBAction)takeFrom:(id)sender {</p><p> fromValue = [sender intValue];</p><p> //[self updateUserInterface];</p><p>}</p><p></p><p>- (IBAction)takeTo:(id)sender {</p><p> toValue = [sender intValue];</p><p> //[self updateUserInterface];</p><p>}</p><p></p><p>- (IBAction)start:(id)sender {</p><p> nombre=fromValue;</p><p> [self updateUserInterface];</p><p> comptage=true;</p><p> if ((fromValue<=toValue)&&(comptage==true)){</p><p> while ((nombre<toValue)&&(comptage==true)) {</p><p> nombre=nombre+1;</p><p> [self updateUserInterface];</p><p> }</p><p> }</p><p>}</p><p></p><p>- (IBAction)stop:(id)sender {</p><p> //nombre=toValue;</p><p> comptage=false;</p><p> [self updateUserInterface];</p><p>}</p><p></p><p>- (void)updateUserInterface {</p><p> [self.champAff setIntValue:nombre];</p><p>}</p><p></p><p>- (id) init{</p><p> self = [super init];</p><p> if (self) {</p><p> fromValue=0;</p><p> toValue=0;</p><p> nombre=0;</p><p> comptage=true;</p><p> return self;</p><p> }</p><p> else</p><p> return nil;</p><p>}</p><p>@end</p><p>[/CODE]</p><p></p><p>And I would like to refresh the textField to display 1,2,3,... and finally 1000, but i have : 1,1000.</p><p></p><p>Could you help me ?</p></blockquote><p></p>
[QUOTE="nico.v.44, post: 1664705, member: 356103"] Thanks, My code is : AppDelegate.h [CODE] #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 [/CODE] AppDelegate.m [CODE] #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 [/CODE] And I would like to refresh the textField to display 1,2,3,... and finally 1000, but i have : 1,1000. Could you help me ? [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Problem Dev Cocoa textField
Top