Open solutions for other Access applications in the SDKAll along, in the development of iOS, it is not allowed to open another application in the program. Then there was the righteous who found such a feature in the private API with Class-dump. That is to use UIApplication's launchapplicationwithidentifier:suspended: to open.The methods used are as follows:
NSString *identifier = [[NSBundle mainbundle] objectforinfodictionarykey:@ "Cfbundleidentifier"];[[
12.2.2. ProgrammeUse UIApplication's Beginbackgroundtaskwithexpirationhandler: Instance method. After you complete the task, call UIApplication's Endbackgroundtask: method.12.2.3. DiscussionWhen an iOS app is sent to the background, its main thread is paused. You use the Nsthread detachnewthreadselector:totar get:withobject: The thread created by the class method is also suspended. If you want to complete a long-term task in the background, you must call UIApplication's Beginbackgroundtaskwithex
The sample code that lets the program run long in the background is as follows:Running in the backgroundAnother use of block is to allow the program to run longer in the background. In the past, when the app was left on the home button, the app only had a maximum of 5 seconds to do some saving or cleanup work. But the app can call the UIApplication beginBackgroundTaskWithExpirationHandler method, allowing the app to run for up to 10 minutes in the bac
//when an application is about to go into an inactive state, during which time the application does not accept messages or events, such as incoming calls- (void) Applicationwillresignactive: (UIApplication *) Application {NSLog (@"the application is going to be inactive and will be entering the background"); } //The application is running in the background- (void) Applicationdidenterbackground: (UIApplication
Briefly describe the life cycle when the application presses the home key into the background and the life cycle from the background back to the foreground? The status of the application: not running is not running, the program does not start inactive inactive, the program runs in the foreground, but does not accept the event, there is no event processing state is usually in this state. The active activator is in the foreground and receives the event Backgound Daemon in the backgroun
Push notification code after the IOS8 version[[UIApplication sharedapplication] registerusernotificationsettings:[uiusernotificationsettings settingsForTypes :(Uiusernotificationtypesound | Uiusernotificationtypealert | Uiusernotificationtypebadge) Categories:nil];Note the following sentence, in IOS8 to register the push notification must be added [[UIApplication sharedapplication] registerforremotenotifica
After reading
Today, I will spend some time collecting some dry goods and then I can say goodbye with this book.
Including:
10.1.3 do not send messages to released objects
Some readers want to test whether the retainCount of an object is changed to 0 when it is released. Their test code is as follows: (remember to set it to MRC-fno-objc-arc in Appdelegate. m)
-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NS
Develop applications to understand their lifecycle.Today we touch the life cycle of the iOS app, the iOS portal in the main.m file:int main (int argc, char * argv[]) { @autoreleasepool { return Uiapplicationmain (argc, argv, Nil, Nsstringfromclas S ([Appdelegate class]));} }The two parameters of the main function are not available in iOS, including the two parameters for consistency with standard ANSI C. The Uiapplicationmain function, like the first two and main functions, focuses
completely removed from memory, freeing up more memory for the foreground app.is the program state change diagram:Callback for the agent when each program is running state:- (BOOL) Application: (uiapplication*) Application Willfinishlaunchingwithoptions: (nsdictionary*) launchoptions//tells the agent process to start but has not yet entered the state to save. The method is called automatically when the application is about to start, the first time th
notificationsNSDate *firedate =[NSDate Datewithtimeintervalsincenow:alerttime]; NSLog (@"firedate=%@", firedate); Notification.firedate=firedate; //Time ZoneNotification.timezone =[Nstimezone Defaulttimezone]; //set the recurrence intervalNotification.repeatinterval =Kcfcalendarunitsecond; //Notification ContentNotification.alertbody =@"It's time to get up ..."; Notification.applicationiconbadgenumber=1; //sounds that are played when notifications are triggeredNotification.soundname =Uilocalnot
number, and so on.
Configure custom data parameter userinfo for notification delivery (this step is optional).
Call notifications, you can use Schedulelocalnotification: Schedule a notification as scheduled, or use Presentlocalnotificationnow to call notifications immediately.
Simple implementation of a local notification application, the specific code is as follows:In Appdelegate:#import"AppDelegate.h"#import"ViewController.h"@interfaceAppdelegate ()@end@implementationappdelegate-
Not much to say directly on the code#import "AppDelegate.h"@interface Appdelegate ()@end@implementation Appdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {Override point for customization after application launch.If you have received authorization to send notifications, create a local notification, or request authorization (note: If you do not request authorization in the settin
= [[Uilocalnotification alloc] init];2. Set content for local notifications2.1. Set the time for the notification to be issued localnote.firedate = [NSDate Datewithtimeintervalsincenow:3.0];2.2. Set the content of the notification Localnote.alertbody =@ "What are you doing?";2.3. Set the text of the slider (lock screen State: swipe to "unlock") Localnote.alertaction =@ "unlock"; //2.4. Decide whether alertaction is effective localnote.hasaction = NO; //2.5. Set the start picture of the click no
stretching, etc. the main ideas of code level include refactoring to eliminate redundancy, selector citation analysis in Linkmap. Besides, is there any other path?As we all know, there is a call relationship between code. Assuming that the main portal for iOS is-[uiapplication main], the source code of all developers (including the third party libraries) can be divided into two categories: there is a call path, so that the code can be finally called
is still in memory, when the system memory is low, the system will remove the suspended program, to provide more memory for the foreground program.
As shown in the following:Active and inactive. png2. UIApplicationMain function Explanation:Entry function:int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } UIApplicationMain(int argc, char *argv[], NSString *principalClassName,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.