accessibity android,IBAction导致AppDelegate中的EXC_BAD_ACCESS

我正在使用DJI Mobile SDK和UXSDK示例应用程序(在这里找到:https://github.com/dji-sdk/Mobile-UXSDK-iOS)在swift中编写iOS项目 .

我添加了一个带有IBAction getData(_ sender :)的ViewController,它成功地向DJI产品发送消息 . 当IBAction完成时,应用程序崩溃并在AppDelegate.swift中出现EXC_BAD_ACCESS错误

AppDelegate中的错误标志

0070b626c8820f1b93104ce7656a5ce5.png

import UIKit

import Foundation

//To use DJI Bridge app, change `useBridge` to true and add bridge app

IP address in `debugID`

let useBridge = false

let debugIP = "BRIDGE_APP_IP_ADDRESS_HERE"

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate,

UISplitViewControllerDelegate {

var window: UIWindow?

open var productCommunicationManager = ProductCommunicationManager()

open var communicationsViewController = CommunicationsViewController()

open var osdkDevice:OnboardSDKDevice?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

// Start the registration at the launch of the app. This can be retriggered at anytime from the main view.

// DJI App key needs to be registered in the Info.plist before calling this method.

self.productCommunicationManager.registerWithProduct()

return true

}

}

这是视图控制器 . 它不是主要的,但它通过主视图控制器导航 .

import UIKit

import Foundation

import DJISDK

import DJIUXSDK

class CommunicationsViewController: UIViewController, UITextViewDelegate {

//This is instantiated as a UIViewController as soon as app launches

//The reference in appDelegate is reassigned every time the view launches

//MARK: Properties

@IBOutlet weak var DataDisplay: UITextView!

open weak var appDelegate = UIApplication.shared.delegate as? AppDelegate

//MARK: Methods

override func viewDidLoad() {

super.viewDidLoad()

appDelegate?.communicationsViewController = self

appDelegate?.productCommunicationManager.connectToProduct()

appDelegate?.productCommunicationManager.connectedProduct = DJISDKManager.product()

if (appDelegate?.productCommunicationManager.connectedProduct?.model != nil){

self.DataDisplay.text = (appDelegate?.productCommunicationManager.connectedProduct.model)

}

appDelegate?.osdkDevice = OnboardSDKDevice()

appDelegate?.osdkDevice?.delegate = appDelegate?.osdkDevice

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

}

//MARK: Actions

@IBAction func back(_ sender: UIButton) {

self.dismiss(animated: true, completion: nil)

}

@IBAction func getData(_ sender: UIButton) {

//Create 4 bytes of 0's

let data = Data(count: 4)

appDelegate?.osdkDevice?.sendDataFromMobile(toOnboard: data, withCompletion: nil)

//App crashes after exiting scope

}

}

我发现EXC_BAD_ACCESS是由尝试访问不再可用的内存引起的 . 我仔细检查了所有IBActions和IBOutlets的连接,它们似乎没问题 .

这是来自控制台

c6b3594d883c1f7b07a966b05c687d46.png

的"bt"的错误消息

异常断点的控制台和程序集

2Yhmc.png

有人可以帮我诊断崩溃吗? iOS编程和Swift对我来说都是新手,所以如果这个描述中有任何遗漏,请告诉我 . 谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值