Differentiate between screen lock and home button press on iOS7

This can help you both on iOS6 & iOS7 :). When user press lock button you will get a com.apple.springboard.lockcomplete notification. //new way //put this in – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, displayStatusChanged, CFSTR(“com.apple.springboard.lockcomplete”), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); //put this function in AppDelegate static void displayStatusChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) … Read more

What is the difference between UIApplication.sharedApplication.delegate.window and UIApplication.sharedApplication.keyWindow?

For most uses, they will be the sameā€¦ but not always. [UIApplication sharedApplication].keyWindow is the window which is currently being displayed on the device. This is normally your application’s window, but could be a system window. [UIApplication sharedApplication].delegate.window is the window your application is expected to use. Which one should be used? Well that all … Read more

What describes the Application Delegate best? How does it fit into the whole concept?

In Cocoa, a delegate is an object that another object defers to on questions of behavior and informs about changes in its state. For instance, a UITableViewDelegate is responsible for answering questions about how the UITableView should behave when selections are made or rows are reordered. It is the object that the UITableView asks when … Read more

-[UIApplication delegate] must be called from main thread only

Just call it from the main thread like this. Objective-C dispatch_async(dispatch_get_main_queue(), ^{ [[UIApplication delegate] fooBar]; }); Swift DispatchQueue.main.async { YourUIControlMethod() } Reaching out to your app delegate like this, is a hint that your architecture could use a little cleanup. You can call delegates from any thread you want. You only need to make sure … Read more

Is this possible to apply the alternative icon to the iOS application?

Yes, this is possible since iOS 10.3. First, you need to define all alternative icons in your Info.plist file, you can’t fetch them dynamically. In the example below we define 2 alternative icons: “de” and “fr”: <key>CFBundleIcons</key> <dict> <key>CFBundleAlternateIcons</key> <dict> <key>de</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_de</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>fr</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_fr</string> </array> … Read more

Adding view on StatusBar in iPhone

You can easily accomplish this by creating your own window above the existing status bar. Just create a simple subclass of UIWindow with the following override of initWithFrame: @interface ACStatusBarOverlayWindow : UIWindow { } @end @implementation ACStatusBarOverlayWindow – (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Place the window on the correct level and … Read more