appcenter-sampleapp-macos-s.../Sample macOS App/AppDelegate.swift

45 строки
1.3 KiB
Swift
Исходник Постоянная ссылка Обычный вид История

2017-10-15 20:35:29 +03:00
import Cocoa
2017-11-16 01:42:05 +03:00
import AppCenter
import AppCenterAnalytics
import AppCenterCrashes
2017-10-15 20:35:29 +03:00
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSPageControllerDelegate {
@IBOutlet weak var window: NSWindow!
@IBOutlet weak var pageController: NSPageController!
private var services: [String] = [ "Welcome", "Build", "Test", "Crashes", "Analytics", "Push"]
func applicationDidFinishLaunching(_ aNotification: Notification) {
2017-11-16 01:42:05 +03:00
// Start App Center
2021-07-30 15:02:15 +03:00
AppCenter.start(withAppSecret: "<APP SECRET HERE>", services: [
Analytics.self,
Crashes.self,
2017-10-15 20:35:29 +03:00
])
pageController.arrangedObjects = services
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
// NSPageController delegate
func pageController(_ pageController: NSPageController, identifierFor object: Any) -> String {
return object as! String
}
func pageController(_ pageController: NSPageController, viewControllerForIdentifier identifier: String) -> NSViewController {
switch identifier {
case "Crashes":
2019-09-19 19:19:56 +03:00
return CrashViewController(nibName: identifier, bundle: nil)
2017-10-15 20:35:29 +03:00
case "Analytics":
2019-09-19 19:19:56 +03:00
return AnalyticsViewController(nibName: identifier, bundle: nil)
2017-10-15 20:35:29 +03:00
default:
2019-09-19 19:19:56 +03:00
return NSViewController(nibName: identifier, bundle: nil)
2017-10-15 20:35:29 +03:00
}
}
}