Animating Progress Indicator in Menu

Send Snippet To: Save this snippet to Code Collector Pro -- view all powidl's snippets
language: Objective-C
license: Other

Code for Snippet:

#import "MyApp.h"
@implementation MyApp
-(id) init
	self = [super init];
	if( self != nil )
		NSTimer *timer = [NSTimer timerWithTimeInterval:0.1 target:self selector:@selector( bumpMainRunLoop: ) userInfo:nil repeats:YES];
		[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode];
	return( self );
-(void) awakeFromNib
	[indicator setUsesThreadedAnimation:YES];
// Clearly the indicator's animator runs in the loop/mode that it gets its startAnimation called from.
//	[indicator startAnimation:nil];
-(void) bumpMainRunLoop:(NSTimer *)timer
	NSLog( @"bump" );
	// Probably a more efficient way of doing this instead of recalling this timer 
	// over and over again.
	[indicator startAnimation:nil];
// These are both the same, one just uses the CF method, the other doesn't.
	[[NSRunLoop mainRunLoop] acceptInputForMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0]];
//	CFRunLoopRunInMode( (CFStringRef)NSDefaultRunLoopMode, 0, true );
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 732
Date Added: 2009-03-02 11:20:10
Last Modified: 0000-00-00 00:00:00

Web Analytics