Hi, there,I apologize for not being able to offer an "Ah-ha!!!" sort of solution immediately, and also for this very long e-mail. I don't know if my suggestions will help, but they may at least lead to cleaner code, and may perhaps solve your problems. If I may...
First, you may wish to rename your class to "VOMainController" or some such -- use a two-letter prefix (one that Apple doesn't use -- and "V" and "O" appear to be your initials), as directed by Apple (as far as I know) to prevent naming collisions, and give it a descriptive name that represents what it is -- "Wnd" seems to be to represent "window," but your class is neither an NSWindowController nor a subclass of NSWindow/NSPanel, and "controller" is a generic class name suffix for such a -- well, for such a controller (hence the convention).
Secondly, instead of using a static xxx = 0 declaration, I'd use an instance variable, and give it a name that will be clear what it represents, then initialize it in your -init method. Also, name it "steps" (or something like that). Also, *you haven't specified what xxx is*!!! I don't know what it defaults to -- but "static xxx = 0" doesn't explicitly make it into an int, a double, or a char -- it may (or may not be) compiler specific. Thus do give it a type.
Thirdly, by making giving the onTimer local variable the name "timer", you have just created a conflict with your instance variable "timer". So I'd rename the *local* one to "aTimer".
Additionally (and this might, or might not, help with your crash), you might want to retain your timer, in case it ever gets removed from the runloop but you wish to keep a reference to it. (Not sure why you'd do that, but it's good form to retain any ivars that are a subclass of NSObject, unless you're using Garbage Collection under Leopard.)
Also: you call [progress setHidden:NO] every time that the timer fires. This may prove inefficient later on, so I'd simply leave it unhidden.
My version of your code follows. Note that it was typed in Mail.app, so there may be an error or two. It should be fairly good to go, though. If you still have the freezing problem, try creating a *new* project under Xcode 2.5, if you haven't already, instead of importing your old one. That might do the trick, if some build settings got corrupted.
// === BEGIN INTERFACE CODE === @interface VOMainController : NSObject {unsigned int steps; // on Leopard you can use "NSUInteger" instead of "unsigned int"
NSTimer *timer; IBOutlet NSProgressIndicator *progress; } // I include these prototypes to show that we've overridden them - (id)init; - (void)dealloc; - (void)awakeFromNib // now for your own method: - (void)onTimer:(NSTImer *)aTimer; @end // === END INTERFACE CODE === // === BEGIN IMPLEMENTATION CODE === @implementation VOMainController - (id)init { self = [super init]; if (self) { steps = 0; } return self; } - (void)dealloc { // there have been debates on this mailing list as to the usefulness of// nullifying instance variables (in this case your timer variable); I do it // since I *feel* it to be good form, even if it appears to be a matter of taste
[timer invalidate]; // very important [timer release]; // since we retained earlier timer = nil; // [super dealloc]; } - (void)awakeFromNib { timer = [[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES] retain]; //[progress setHidden:YES]; } - (void)onTimer:(NSTimer *)aTimer { steps = (steps + 1) % 100; [progress setDoubleValue:steps]; //[progress setHidden:NO]; } @end // === END IMPLEMENTATION CODE === Cheers, Andrew On May 20, 2008, at 2:52 PM, Vitaly Ovchinnikov wrote:
It is working fine for me using Mac OS X 10.5 and Mac OS X 10.4 when compiled with Xcode 2.5 against the 10.4u SDK (not tried any other version of Xcode or SDK).just installed XCode 2.5 and tried the demo project - result is the same, progress freezes. I have a slow computer, maybe the reason is here. it is G4 1.4GHz with 1 Gb RAM... _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/andrew.merenbach%40ucla.edu This email sent to [EMAIL PROTECTED]
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]