appdelegate

iOS Background Fetch and completion block

旧时模样 提交于 2019-12-08 01:54:49
问题 I am trying to define this method - (void)backgroundFetchWithCompletion:(void(^)(UIBackgroundFetchResult))completionHandler; However I am getting an error on UIBackgroundFetchResult saying a parameter list without types is only allowed, I was following this tutorial and this tutorial and that is how they define their method. 回答1: After executing some operation at the end you must call one in list. Objective-C completionHandler(UIBackgroundFetchResultNewData); completionHandler

How to show alert in all controllers without repeating the code?

微笑、不失礼 提交于 2019-12-08 01:08:26
问题 I want to write one function alert() and to run it. But I want to show this alert in any controllers without repeating the code. For example: I have Presence.swift class and here I have some condition, as: if myVar == 1 { // Just for presenting runMyAlert() } and when in the background myVar == 1 user, regardless of the fact that where he is, on which screen, he gets alert on screen. How can I do it without repeating my code? I tried to make it in AppDelegate as: func alert(title : String

How to properly use the completionHandler when performing a background fetch?

戏子无情 提交于 2019-12-07 11:27:29
I'm having a hard time wrapping my head around using completionHandler inside performFetchWithCompletionHandler in the AppDelegate . My App does some background fetching, and during the fetch I would like to invoke a function that is located in one of my viewControllers What is the correct way to use the completionHandler , I'm aware that it is an asynchronous task. I managed to make it work when I wanted to send data to my database, but I'm unable to make it work when I want to invoke a function located in one of the viewControllers Attempt : What is the right way to call completionHandler ?

How to share iAd banner between views using AppDelegate

我的梦境 提交于 2019-12-07 09:57:45
问题 I am looking to implement iAd in my app. So far I have managed to get them showing/dismissing correctly in each view using the below. App Delegate: import UIKit import iAd @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var adBannerView = ADBannerView() View Controller 1: import UIKit import iAd class HomeScreenViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, ADBannerViewDelegate { let appDelegate = UIApplication

'UIApplicationMain' attribute cannot be used in a module that contains top-level code

↘锁芯ラ 提交于 2019-12-07 05:51:16
问题 All of a suden I got this error in my AppDelegate: 'UIApplicationMain' attribute cannot be used in a module that contains top-level code in the line where it says: @UIApplicationMain Now the project cannot build. I am using Swift and Xcode 6.2. I have tried deleting the derived data folder and even using the latest Xcode 6.3 beta, which was where I first created the project. I don't know what's going on and I have searched everywhere with no luck. Thank you 回答1: Ok, I finally solved it myself

How does AppDelegate.swift replace AppDelegate.h and AppDelegate.m in Xcode 6.3

血红的双手。 提交于 2019-12-07 02:15:37
问题 According to the iOS Developer Library The app delegate is where you write your custom app-level code. Like all classes, the AppDelegate class is defined in two source code files in your app: in the interface file, AppDelegate.h, and in the implementation file, AppDelegate.m. However, in Xcode 6.3 it appears that there is only AppDelegate.swift and no longer the .h and .m extensions. I would like to understand how the .swift replaced both the .h and .m extensions. 回答1: The simple answer is

UINavigationBar set custom shadow in AppDelegate.swift

放肆的年华 提交于 2019-12-07 02:06:06
问题 I want to set some shadow to the bottom of my UINavigationBar for the whole application. Here is what I've tried but it doesn't work: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { UINavigationBar.appearance().layer.shadowOffset = CGSizeMake(0, 3) UINavigationBar.appearance().layer.shadowRadius = 3.0 UINavigationBar.appearance().layer.shadowColor = UIColor.yellowColor().CGColor UINavigationBar.appearance().layer

Core Data NSManagedObject doesn't have a valid NSEntityDescription

拜拜、爱过 提交于 2019-12-06 16:46:11
问题 I am trying to set up core data with my Xcode project and running into an error that I can't seem to get rid of. I have an entity called UserDetails inside of StudyHub.xcdatamodeld . My code in the AppDelegate: // MARK: - Core Data stack lazy var persistentContainer: NSPersistentContainer = { /* The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it. This property is optional since there are

openURL in APPDelegate conversion error NSString -> String (Swift & iOS8)

给你一囗甜甜゛ 提交于 2019-12-06 14:19:48
问题 I'm currently developing an iOS application that integrates Facebook and I'm having a bit of a problem while investigating this with Swift (with ObjC I have no problems). The thing is, this is the method that gets executed in the appDelegate when coming from another APP (in this case FB in a WebBrowser): func application( application: UIApplication, openURL url: NSURL, sourceApplication: NSString, annotation: AnyObject) -> Bool { let appString : String = sourceApplication as String // Try to

How to show alert in all controllers without repeating the code?

醉酒当歌 提交于 2019-12-06 11:12:35
I want to write one function alert() and to run it. But I want to show this alert in any controllers without repeating the code. For example: I have Presence.swift class and here I have some condition, as: if myVar == 1 { // Just for presenting runMyAlert() } and when in the background myVar == 1 user, regardless of the fact that where he is, on which screen, he gets alert on screen. How can I do it without repeating my code? I tried to make it in AppDelegate as: func alert(title : String,message : String,buttonTitle : String,window: UIWindow){ let alert = UIAlertController(title: title,