我正试图在我的HomeKitDemoApp中添加一个主页。当我第一次在设备或模拟器上安装应用程序时,我会看到HomeKitDemoApp喜欢访问我的附件数据的弹出窗口,我按OK,它接缝到工作,房间被添加到我的桌面视图中。在我在同一个设备或模拟器设备上重建应用程序之后,我不会把房间放到我的桌面视图中。现在我得到了一个错误:
HomeKitDemoApp[22635:1632134] Add home error:Error Domain=HMErrorDomain Code=49 "The operation couldn’t be completed. (HMErrorDomain error 49.)"我的代码是:
import Foundation
import UIKit
import HomeKit
class HomeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, HMHomeManagerDelegate{
var homeManager:HMHomeManager = HMHomeManager()
@IBOutlet var homesTableView: UITableView!
var homes = [AnyObject]()
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
@IBAction func addHome(sender: AnyObject) {
let alert:UIAlertController = UIAlertController(title: "Zuhause hinzufügen", message: "Neues Zuhause zu HomeKit hinzufügen", preferredStyle: .Alert)
alert.addTextFieldWithConfigurationHandler(nil)
alert.addAction(UIAlertAction (title: "abbruch", style: UIAlertActionStyle.Cancel, handler: nil))
alert.addAction(UIAlertAction(title: "hinzufügen", style: UIAlertActionStyle.Default, handler:
{
(action:UIAlertAction!) in
let textField = alert.textFields?[0] as UITextField
//create home with the typed name
self.homeManager.addHomeWithName(textField.text, completionHandler:
{
(home: HMHome!,error )in
if let error = error {
NSLog("Add home error:\(error)")
}else{
println("im here in reloaddata")
self.homes.append(home)
self.homesTableView.reloadData()
}
}
)
}))
self.presentViewController(alert, animated: true, completion: nil)
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("CustomHomeCell", forIndexPath: indexPath) as UITableViewCell
let home = self.homeManager.homes?[indexPath.row] as HMHome
cell.textLabel?.text = home.name
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return homes.count
}
// #pragma mark - HMHomeManager Delegate
func homeManagerDidUpdateHomes(manager: HMHomeManager!) {
self.homes = manager.homes
self.homesTableView.reloadData()
}
}希望任何人都有想法并能帮助我。谢谢。
发布于 2015-03-18 08:05:48
添加主页的最大限制是10。Homekit将不允许添加超过10个主页。
发布于 2015-02-13 21:41:44
看来你的家太多了。我不知道限制是什么,但当你重建应用程序时,房屋不会被移除。它们(以及所有其他的homekit数据)保存在一个连接到iCloud帐户的共享数据库中。
你建了多少栋房子?
发布于 2015-10-18 18:40:35
HomeKit将允许最多增加10个家庭。要从iOS设备和iCloud中删除所有家庭数据,请转到设置>隐私> HomeKit并点击“重置HomeKit配置”。将应用程序从设备中删除并重新安装将不会清除HomeKit配置。
hth
https://stackoverflow.com/questions/26389194
复制相似问题