Skip to main content

Posts

Showing posts from April, 2012

MKMoviPlayer Notification

Some Notifications that generates MKMoviePlayer: MPMoviePlayerPlaybackStateDidChangeNotification MPMoviePlayerLoadStateDidChangeNotification [[ NSNotificationCenter defaultCenter ] addObserver : self                                              selector : @selector ( playBackStateChanged :)                                                  name : MPMoviePlayerLoadStateDidChangeNotification                                                 object : moviePlayerViewController . moviePlayer ]; -( void ) playBackStateChanged :( id ) sender {     MPMoviePlaybackState playbackState = [ moviePlayerViewController . moviePlayer playbackState ];     switch ( playbackState ) {         case MPMoviePlaybackStateStopped :             break ;         case MPMoviePlaybackStatePlaying :             [ yourActivityIndicatorView stopAnimating ];             break ;         case MPMoviePlaybackStateInterrupted :             [ yourActivityIndicatorView startAnimat

UIWebView crash due to separate thread

Fixed the crash due to separate thread : -(void)viewDidLoad{     NSOperationQueue *operationQueue = [[ NSOperationQueue alloc ] init ]; NSInvocationOperation *operation = [[ NSInvocationOperation alloc ] initWithTarget : self selector : @selector (load) object : nil ]; [operationQueue addOperation :operation]; [operation release ]; [operationQueue release ]; } -( void )load {     [ NSThread sleepForTimeInterval : 1 ];     [ self performSelectorOnMainThread : @selector (loadWebView) withObject : nil waitUntilDone : NO ]; } -( void )loadWebView{     NSLog ( @"Runnnnn...." );           UIWebView *webView = [[ UIWebView alloc ] initWithFrame : self . view . bounds ];     [webView setUserInteractionEnabled : YES ];     NSString *docsDirectory =         [ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory , NSUserDomainMask , YES ) objectAtIndex : 0 ]; NSString *newDirectory = [ NSString stringWithFormat : @"%@