appdelegate

How to convert from UIKit life cycle to SwiftUI life cycle in iOS 14 (Xcode 12 Beta)

孤者浪人 提交于 2020-08-23 05:45:24
问题 I am currently working on SwiftUI app in which I am using SceneDelegate and AppDelegate . I would like to know how I can convert the life cycle from UIKit to SwiftUI one where there is an App struct and with scenes etc. Also I would like to know how to cater for CoreData and PersistentContainers and inject these into our environments. Also I have used UIApplicationDelegateAdapter to inject AppDelegate but the @main is giving me error 'main()' is only available in iOS 14.0 or newer I am using

How to convert from UIKit life cycle to SwiftUI life cycle in iOS 14 (Xcode 12 Beta)

纵然是瞬间 提交于 2020-08-23 05:42:13
问题 I am currently working on SwiftUI app in which I am using SceneDelegate and AppDelegate . I would like to know how I can convert the life cycle from UIKit to SwiftUI one where there is an App struct and with scenes etc. Also I would like to know how to cater for CoreData and PersistentContainers and inject these into our environments. Also I have used UIApplicationDelegateAdapter to inject AppDelegate but the @main is giving me error 'main()' is only available in iOS 14.0 or newer I am using

App Delegate Accessing Environment Object

孤街浪徒 提交于 2020-07-01 15:47:44
问题 I've got a variable (a label which describes a play) within a class that I need to pass around between my views, which I do through the @EnvironmentObject state. When a function (in the same class as the variable) that changes that label gets called by one view the variable is updated in the other views. However, that function is also called by the AppDelegate when a notification is fired. At the moment, I've got the class containing the label declared as a new instance in the AppDelegate,

How to NOT handle some Universal Links programmatically?

邮差的信 提交于 2020-06-28 04:06:34
问题 My iOS application handles universal links to redirect safari users to my app. So far everything is working great, if a user tap a link to my web site from Google my app is opening instead of my web site like this: from safari https://my-web-site.com -> my-app But my app doesn't implement certains features that my web site does, so I would like to programmatically reject some URLs and let my users on safari instead of redirecting him in my app, like this: from safari https://my-web-site.com -

Setting Up CoreData with SceneDelegate - unknown identifier 'window' error - iOS 13 onwards

微笑、不失礼 提交于 2020-05-29 11:57:57
问题 I was trying to use the official apple documentation for Core Data. Found here. I also ran into a question which was related to my issue, right here on stack. I ran into an issue where, it kept saying that 'window' is not available in the context of AppDelegate. This is the very basic step as per the official documentation. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if let rootVC = window?

NSCache removes all its data when app goes to background State

江枫思渺然 提交于 2020-05-27 05:40:40
问题 I am working with NSCache , I am using NSCache to store images. I am showing images on UITableView . Whenever I add images first they are resized and then added to the table and then to NSCache . eveything works fine. But whenever app goes to background when I close the app and open again, My Cache will be empty and again my app resizes images and then show it, because of which at first I see a empty table. I am not understanding why this is happening. Is this the intended behaviour of

Bi-Directional communication between ViewController and AppDelegate with swift 2 for iOS

ⅰ亾dé卋堺 提交于 2020-04-30 07:45:10
问题 I am developing an iPhone app that uses the PubNub network to publish data to a Raspberry Pi and subscribe to messages from it. Xcode 7, Swift 2. These messages are sent using an object that I call client, which is declared in the AppDelegate.swift init() method. I have been able to successfully reference my AppDelegate from my one and only ViewController, however getting data back to my ViewController from the AppDelegate is where things have gotten tricky for me. I'm aware that this bi

AppDelegate and SceneDelegate when supporting iOS 12 and 13

橙三吉。 提交于 2020-04-27 04:40:14
问题 I need to support iOS 12 and iOS 13. Should I be duplicating code between AppDelegate and SceneDelegate ? For example: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } let window = UIWindow(windowScene: windowScene) window.rootViewController = HomeViewController() window.makeKeyAndVisible() self.window = window } and func application(_ application:

AppDelegate and SceneDelegate when supporting iOS 12 and 13

一世执手 提交于 2020-04-27 04:37:52
问题 I need to support iOS 12 and iOS 13. Should I be duplicating code between AppDelegate and SceneDelegate ? For example: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } let window = UIWindow(windowScene: windowScene) window.rootViewController = HomeViewController() window.makeKeyAndVisible() self.window = window } and func application(_ application: