AppConnect Error : AppConnect cannot be instantiated directly

[亡魂溺海] 提交于 2019-12-10 11:28:48

问题


I am trying to Access the MDM using AppConnect SDK in swift 1.2 but it is giving following error :

[AppConnect:Error] AppConnect cannot be instantiated directly. Instead, call +initWithDelegate: and then +sharedInstance.

Code Snippet :

 import UIKit

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate, AppConnectDelegate {

        var window: UIWindow?        
        var appct = AppConnect()

        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            // Override point for customization after application launch.   

            // Initialize the AppConnect library
            AppConnect.initWithDelegate(self)
            self.appct = AppConnect.sharedInstance()
            self.appct.startWithLaunchOptions(launchOptions)

            return true
        } 
}

Application is crashing while accessing the Keys of MobileIron Backend Config file.

Any other way to implement this?


回答1:


You are initializing AppConnect without delegate

change

var appct = AppConnect();

to

var appct : AppConnect!;




回答2:


My solution was to set a new key/value in the plist:

Principal class AppConnectUIApplication

or in source mode:

  <key>NSPrincipalClass</key>
    <string>AppConnectUIApplication</string>

Hope it help you



来源:https://stackoverflow.com/questions/37024457/appconnect-error-appconnect-cannot-be-instantiated-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!