我有一个问题,通过IOBluetooth框架列出所有设备.有没有办法不仅可以获得经典设备,还可以获得BLE设备?
我的代码是
let ioBluetoothManager = IOBluetoothDeviceInquiry(delegate: self)
var ioDevices = [IOBluetoothDevice]()
...
ioBluetoothManager?.start()
...
func deviceInquiryStarted(_ sender: IOBluetoothDeviceInquiry!) {
print("started")
}
///
//IOBluetoothDeviceInquiryDelegate
///
func deviceInquiryDeviceFound(_ sender: IOBluetoothDeviceInquiry!, device: IOBluetoothDevice!) {
print("found device")
ioDevices.append(device)
scrubber.reloadData()
tableView.reloadData()
}
func deviceInquiryComplete(_ sender: IOBluetoothDeviceInquiry!, error: IOReturn, aborted: Bool) {
print("completed")
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以用CoreBluetooth做到这一点,但我还需要过滤设备以符合某个标准.
从这个答案我知道我可以做到这一点,但答案缺乏细节.现在我只是获得经典蓝牙设备列表.
有人可以帮忙吗?
UPD:
现在我找到了.searchType方法kIOBluetoothDeviceSearchClassic和kIOBluetoothDeviceSearchLE常量.在viewDidLoad中,我执行了以下操作:
ioBlutoothmanager.searchType = IOBluetoothDeviceSearchLE.rawValue 但它仍然只能找到经典的设备.
UPD:
这段时间它的工作正常我没想到.它过滤了我不需要的所有设备,我没有AirPods来检查.
我在9.3更新中遇到此崩溃,在9.2上一切正常.它能是什么?通过任何来源登录时出现错误(登录通行证,VK,谷歌)
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
private let settingsManager = SettingsManager.manager
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Googole Map
GMSServices.provideAPIKey("-k")
UINavigationBar.appearance().tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
UINavigationBar.appearance().barTintColor = #colorLiteral(red: 0.2069905996, green: 0.2386507988, blue: 0.3337202668, alpha: 1)
UITabBar.appearance().tintColor = #colorLiteral(red: 0.2069905996, green: 0.2386507988, blue: 0.3337202668, alpha: 1)
let barFont = UIFont.systemFont(ofSize: 20)
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1), NSFontAttributeName: barFont]
if settingsManager.isFirstStartApp …Run Code Online (Sandbox Code Playgroud) 我对编程很新,所以我有一个简单的问题.实际上,写作可以帮助我更快地识别问题.
无论如何,我有一个多个异步调用的应用程序,它们嵌套如下:
InstagramUnoficialAPI.shared.getUserId(from: username, success: { (userId) in
InstagramUnoficialAPI.shared.fetchRecentMedia(from: userId, success: { (data) in
InstagramUnoficialAPI.shared.parseMediaJSON(from: data, success: { (media) in
guard let items = media.items else { return }
self.sortMediaToCategories(media: items, success: {
print("success")
// Error Handlers
Run Code Online (Sandbox Code Playgroud)
看起来很可怕,但那不是重点.一旦我开始工作,我将调查Promise Kit.
我需要sortMediaToCategories等待完成然后重新加载我的集合视图.但是,在sortMediaToCategories我有另一个嵌套函数,它也是异步并且具有for循环.
func sortMediaToCategories(media items: [StoryData.Items],
success: @escaping (() -> Swift.Void),
failure: @escaping (() -> Swift.Void)) {
let group = DispatchGroup()
group.enter()
for item in items {
if item.media_type == 1 {
guard let url = URL(string: (item.image_versions2?.candidates?.first!.url)!) …Run Code Online (Sandbox Code Playgroud) 尝试重置实体的父代或删除实体的父代时发生此崩溃。
这是当机报告
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
ProductBuildVersion: 9E145
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEPlugins/IDEPlugins-14133/IDECoreDataModeler/ModelEditor/EditorShared/XDDiagram/XDDiagramStorage.m:364
Details: (graphic) should not be nil.
Object: <XDDiagramStorage: 0x7fa373ec1b50>
Method: -removeGraphic:
Thread: <NSThread: 0x7fa36a619650>{number = 1, name = main}
Run Code Online (Sandbox Code Playgroud)
关于我做错了什么的任何想法,或者如果这是Xcode错误,如何避免崩溃?
我 在项目中使用滑动菜单控制器窗格,但遇到了一些问题。当导航堆栈中有控制器并且我想向左滑动时,会出现汉堡菜单,而不是弹出控制器。这怎么能改变呢?有人可以指导我吗?
所以我知道这是一个非常基本的功能,您可以免费获得,但它在这里被覆盖。
我尝试关闭幻灯片菜单的平移手势,但它关闭了整个机制。
SlideMenuOptions.panGesturesEnabled = false
我也找到了handleLeftPanGesture(_ panGesture: UIPanGestureRecognizer)方法,如下所示:
open func isTargetViewController() -> Bool {
// Function to determine the target ViewController
// Please to override it if necessary
guard let navController = navigationController else { return true }
return navController.viewControllers.isEmpty
}
@objc func handleLeftPanGesture(_ panGesture: UIPanGestureRecognizer) {
if !isTargetViewController() {
navigationController?.popViewController(animated: true)
}
if isRightOpen() {
return
}
switch panGesture.state {
case UIGestureRecognizerState.began:
if LeftPanState.lastState != .ended && LeftPanState.lastState != .cancelled && LeftPanState.lastState != …Run Code Online (Sandbox Code Playgroud)