背景中EAAccessory / EASession拆除 [英] EAAccessory/EASession teardown during background

查看:981
本文介绍了背景中EAAccessory / EASession拆除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

利用苹果公司的EADemo作为基础,我试图理解一个后台对EAAccessories影响。

Using Apple's EADemo as a base I'm trying to understand backgrounding's influence on EAAccessories.

当我收到connectNotification,我得到的附件,检查协议,并获得流。随着流我设定的委托,计划在RunLoop,并打开

When I receive a connectNotification, I get the accessory, check the protocol and get the streams. With the streams I set the delegate, schedule on the RunLoop, and open

目前,当我进入我撕这一切下降的背景。我背了一切,我没有和释放所有对象。

Currently when I go into the background I tear this all down. I back out everything I did and release all objects.

我也这样做拆解上didDisconnect。

I also do this teardown on a didDisconnect.

入境时,我并不总是得到didConnect所以我走了connectedAccessory列表,并查看相应的设备。

Upon entry, I don't always get a didConnect so I walk the connectedAccessory list and check for appropriate devices.

- = - = - = -

-=-=-=-

EA的演示设置,并断开会话视图上的,所以我们看不到是否有背景的持久性。

The EA Demo sets up and tears down sessions on a view so we don't see whether there is background persistence.

EA的演示code似乎在暗示你可以推倒,并回去只要设备本身并没有断开连接。

The EA Demo code seems to suggest you can tear down and go back in as long as the device itself hasn't disconnected.

会议及然而,设备有时似乎进入一个状态时,iOS设备已经睡或将应用程序进入后台,设备将停止承认数据还是差将停止拉出流数据到如此地步,流满了。

The session and the device however sometimes seem to get into a state when the iOS device has slept or put the app into the background and the device will stop acknowledging data or worse will stop pulling data out of the stream to the point that the stream fills up.

问题:当使用一个后台,我应该不会推倒会话/配件,有效,除非我居然得到了didDisconnect通知。有了这个,我认为会话和附属结构(也许流)将在后台生存?

Question: When using backgrounding, should I not tear down a session/accessory that is active unless I actually get a didDisconnect notification. With this I assume that the Session and Accessory structures (and maybe the streams) will survive in the background?

推荐答案

我与外部附件框架的经验是,它最初是设计不当,在坚固性方面。直到iOS的4.0,尝试连接到多个配件会产生此错误消息:

My experience with the External Accessory framework is that it was poorly designed initially, in terms of robustness. Until iOS 4.0, trying to connect to multiple accessories would yield this error message:

Cannot use accessory. Only one accessory can be in use at a time.

现在似乎有没有受到太多关注,当应用程序进入到了后台发生了什么配件。我一直相信,正确的行为是对附件断开释放EASession实例。但我不认为一个应用程序进入后台资格作为断开连接的附件。没有太多的如果您登录的connectedID为您的配件的价值去了,你会发现,他们的不可以的变化只是已经切换到后台,并返回到前台。我怀疑连EAAccessory实例列表不刷新,除非EAAccessoryManager通知变更的附件(连接/断开)。

Now it seems that there has not been much attention to what happens to accessories when apps go into the background. I have been assured that the correct behavior is for EASession instances to be released on accessory disconnect. But I don't think that an app going into the background qualifies as an accessory being disconnected. There isn't much to go by if you log the value of the connectedID for your accessories, you will notice that they do not change just for having switched to background and back to foreground. I suspect that the list of connected EAAccessory instances is not refreshed unless EAAccessoryManager is notified of a change (connect/disconnect) of an accessory.

我一直在试图拆除并重建EASession实例,但未能成功。现在我要去尝试离开EASession到位整个背景/前景的过渡。我唯一​​担心的是,我的应用程序不会在后台接受EAAccessoryDidDisconnectNotification和EAAccessoryDidConnectNotification通知,而

I have been trying to teardown and recreate EASession instances and this has failed. I am now going to try leaving the EASession in place throughout the background/foreground transition. My one concern is that my app won't be receiving EAAccessoryDidDisconnectNotification and EAAccessoryDidConnectNotification notifications while in background.

这篇关于背景中EAAccessory / EASession拆除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆