Skip to main content

Posts

NSDateFormatter

/*     x           number     xx          two digit number     xxx         abbreviated name     xxxx        full name     a           AM/PM     A           millisecond of day     c           day of week (c,cc,ccc,cccc)     d           day of month     e           day of week (e,EEE,EEEE)     F           week of month     g           julian day (since 1/1/4713 BC)     G           era designator (G=GGG,GGGG)     h           hour (1-12, zero padded)     H           hour (0-23, zero padded)     L   ...

Write text file in Document Directory

//Method writes a string to a text file -( void ) writeToTextFile:(NSString*)fileText{ //get the documents directory: NSArray *paths = NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory ,  NSUserDomainMask ,  YES ); NSString *documentsDirectory = [paths  objectAtIndex : 0 ]; //make a file name to write the data to using the documents directory: NSString *fileName = [ NSString   stringWithFormat : @"%@/textfile.txt" ,    documentsDirectory]; //save content to the documents directory [fileText  writeToFile :fileName     atomically : NO   encoding : NSStringEncodingConversionAllowLossy       error : nil ]; }

Show AdMob

// Initialize the banner at the bottom of the screen.     CGPoint origin = CGPointMake ( 0.0 ,                                  self . view . frame . size . height -                                  CGSizeFromGADAdSize ( kGADAdSizeBanner ). height ); // Use predefined GADAdSize constants to define the GADBannerView.     bannerView_ = [[ GADBannerView alloc ] initWithAdSize : kGADAdSizeBanner                                                     origin :origin]                      ; // Note: Provide a definition for ADMOB_ID     // before compiling...

Resize Image Frame

Get the image frame size as per the image size ratio : -( CGRect )imagePosition:( int )imgWidth forImageHeight:( int )imgHeight maxFrame:( CGRect ) rect { float xPos=rect. origin . x , yPos=rect. origin . y ; int maxWidth=rect. size . width ; int maxHeight=rect. size . height ; float imgCWidth=imgWidth; float imgCHeight=imgHeight; float ratio= 0 ; if (imgCHeight> 0 ) ratio=( float )imgCHeight/( float )imgCWidth; if (imgCWidth>imgCHeight) { if (imgCWidth>maxWidth) { imgCWidth=maxWidth; imgCHeight=imgCWidth*ratio; } if (imgCHeight>maxHeight) { imgCHeight=maxHeight; imgCWidth=imgCHeight/ratio; } } else { if (imgCHeight>maxHeight) { imgCHeight=maxHeight; imgCWidth=imgCHeight/ratio; } if (imgCWidth>maxWidth) { imgCWidth=maxWidth; imgCHeight=imgCWidth*ratio; } } maxWidth=imgCWidth; maxHeight=imgCHeigh...

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 = [ moviePlayerViewControl...