Questions tagged [uiapplication]

The UIApplication class provides a centralized point of control and coordination for apps running on iOS. Every app must have exactly one instance of UIApplication (or a subclass of UIApplication). When an app is launched, the UIApplicationMain function is called; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access this object by invoking the sharedApplication class method.

The UIApplication class provides a centralized point of control and coordination for apps running on iOS. Every app must have exactly one instance of UIApplication (or a subclass of UIApplication). When an app is launched, the UIApplicationMain function is called; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access this object by invoking the sharedApplication class method.

A major role of a UIApplication object is to handle the initial routing of incoming user events. It also dispatches action messages forwarded to it by control objects (UIControl) to the appropriate target objects. In addition, the UIApplication object maintains a list of all the windows (UIWindow objects) currently open in the app, so through those it can retrieve any of the app’s UIView objects. The app object is typically assigned a delegate, an object that the app informs of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately.

Apps can cooperatively handle a resource such as an email or an image file through the openURL: method. For example, an app opening an email URL with this method may cause the mail client to launch and display the message.

The programmatic interfaces of UIApplication allow you to manage behavior that is specific to the device. Use this object to do the following:

  • Control the app’s response to changes in interface orientation.

  • Temporarily suspend incoming touch events.

  • Turn proximity sensing (of the user’s face) off and on again.

  • Register for remote notifications.

  • Trigger the undo-redo UI (applicationSupportsShakeToEdit).

  • Determine whether an installed app can open a URL (canOpenURL:).

  • Extend the execution of the app so that it can finish a task in the background.

  • Schedule and cancel local notifications.

  • Coordinate the reception of remote-control events.

  • Perform app-level state restoration tasks.

UIApplication defines a delegate that must adopt the UIApplicationDelegate protocol and implement some of the protocol methods.

Subclassing Notes

Most apps should never need to subclass the UIApplication class. Most apps use an app delegate to manage interactions between the system and the app.

The only situation where you might need to subclass UIApplication is when you are implementing a custom event or action dispatching mechanism. In that situation, you might override the sendEvent: or sendAction:to:from:forEvent: methods to implement that mechanism. However, the cases where this is required are very rare and should be avoided whenever possible.

484 questions
0
votes
1 answer

Run network connection in background mode

I have this code who send data and receive even when the application is in background mode (minimized app): MyViewController.m -(void)viewDidAppear:(BOOL)animated{ [self doUpdateEvenAppMinimized]; } - (void) doUpdate{ …
LettersBa
  • 747
  • 1
  • 8
  • 27
0
votes
1 answer

I am trying to use swift to invoke another application passing a file with no joy

I am trying to invoke an external application such as Numbers (.numbers) or Safari (.htm). I have tested this with an internet URL and this works (with slight changes to the code here). I tried to use a htm to invoke Safari local access but no…
0
votes
1 answer

UIApplicationDidEnterBackgroundNotification delivered after entering foreground

I register my VC for UIApplicationDidEnterBackgroundNotification [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackgroundNotification:) name:UIApplicationDidEnterBackgroundNotification…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
0
votes
1 answer

Save UITableView property when applicationDidEnterBackground and load back it applicationDidBecomeActive in iOS

In my iOS application, I'm having a UITableView inside my UIViewController. After data loading completed to the UITableView, when I press the Home button of the iPhone, the application will enter to the background. It will execute following…
AnujAroshA
  • 4,623
  • 8
  • 56
  • 99
0
votes
0 answers

UIApplication subclassing options

We all know that normally we don't have any UIApplication subclasses in iOS applications. I have noticed that UIApplication is subclassed for implementing timeout functionality in applications. In that purpose we can catch 'sentEvent:' method fired…
0
votes
0 answers

UIEvent detection and handling

My app has many threads, so I do get lot of crashes when the same variable is updated and read at the same time. To solve this issue I decided to use NSLock and lock it when the variables are updated and similarly lock it when I get an event Ex:…
Agarathi
  • 148
  • 1
  • 14
0
votes
0 answers

How to send a Whatsapp message to a specific user using third party apps in iPhone?

Let my app be A and the app user is called A1 I have a completely different person with his mobile mobile number - N1 Now I want achieve the following in my app A - When the user A1 clicks on a button, Whatsapp is opened(if present) with a compose…
rahulg
  • 2,183
  • 3
  • 33
  • 47
0
votes
2 answers

How to switch view controllers from UIApplication

Basically, I have a timer set up in an uiapplication to check if the user is idle, and what I want to happen is that if the user is idle long enough, the viewcontroller on top will be the initial log in one. The timer part works, I've tried it with…
0
votes
1 answer

When notification is dragged and released, ApplicationBecomeActive gets called in iOS

I have password option in my app, so if user sets a password, then I show a password page first when app becomes active and user should enter the password to use the app I have written the code this way -…
Ranjit
  • 4,576
  • 11
  • 62
  • 121
0
votes
0 answers

iOS iPhone can't open generated/saved KML file with Google Earth App

with the following code i try to open a generated and saved KML file in Google Earth App. Google Earth app opens but it do nothing. When i send this file with email and open it with GE App it works fine. is there a way to open mml from my app in…
Kevin
  • 115
  • 1
  • 10
0
votes
1 answer

UIAlertView button not working

I want the cancel button of my UIAlertView to launch the app store so that my app can be updated. I can get the app to launch the app store, but I want it to launch only when the cancel button of my UIAlertView is pressed. The way I have it now,…
0
votes
2 answers

UIApplication sharedApplication called twice

I have a Subview that has a button, when tapped opens up the map and location. There is no error in code but once I get sent to Maps and get back to my app.. It opens Maps once again. So I guess the method is being called twice. How do I stop…
adriennemhenry
  • 133
  • 1
  • 3
  • 17
0
votes
1 answer

Will openURL: method of UIApplication will open URL only in safari always?

I am trying to open a html file from my iPhone/iPad app particularly in Safari. I use openURL method of UIApplication after checking canOpenURL. I doubt if the link will always be opened in Safari. Even in jailbreak iPhones and iPads. If not can I…
aparna
  • 353
  • 2
  • 3
  • 13
0
votes
1 answer

Call UIApplication sharedApplication openURL from background

I need return to app after call. Or i need make phone call from background. NSURL *url = [NSURL URLWithString:@"tel://%@",phoneNumber]; if([[UIApplication sharedApplication]canOpenURL:url]) { [[UIApplication…
Dmitriy Pushkarev
  • 390
  • 2
  • 5
  • 26
0
votes
1 answer

Run process in Background iOS7

I've a question: I'm writing an application. This application have many function. One of this functions need to works also in background. This function don't needs download data or use a standard process (i've found many page with example to explain…
Paoloandrea
  • 121
  • 1
  • 1
  • 5