Gets the global delegate object so that we can invoke the methods and variables in this object
[[UIApplication Sharedapplication] delegate];
Get the main bundle of the program
NSBundle *bundle = [NSBundle mainbundle];
/*
Play a sound in the program
1. Add Audiotoolbox Frame
*/
NSString *path = [Bundle pathforresource:@ "Soundfilename" oftype:@ "wav"];
Systemsoundid Soundid;
Audioservicescreatesystemsoundid ((__bridge cfurlref) ([Nsurl Urlwithstring:path]), &soundid);
Audioservicesplayalertsound (Soundid);
Capture program shuts down or enters background events
UIApplication *application = [UIApplication sharedapplication];
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (applicationwillresignactive:) Name: Uiapplicationwillresignactivenotification Object:application];
}
-(void) Applicationwillresignactive: (nsnotification *) noti{
}
#pragma mark-Get a screenshot
-(UIImage *) getscreenshot{
Uigraphicsbeginimagecontext (self.view.bounds.size);
[Self.view.layer Renderincontext:uigraphicsgetcurrentcontext ()];
UIImage *image = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
return image;
}
Some common little knowledge points of iOS