运行斯坦福的CS193p Smashtag应用程序时_BSMachError [英] _BSMachError while running Stanford's CS193p Smashtag app
问题描述
我从课程网站下载了Smasthag演示应用程序。项目构建良好(在Twitter,TwitterRequest等类的小变化之后,因为我使用最新的Xcode 7b4)并且在模拟器上工作正常(我还必须添加 NSAppTransportSecurity
键到 info.plist
),但不在设备上 - 它不会提取推文。我在带有iOS 9 Public Beta的iPhone 6和带有iOS 8.4的iPad 2上进行了测试。此外,当app在模拟器中运行并且我更改了hashtag以进行搜索时,整个tableView会重新加载新的推文,但在控制台中我得到了这个:
I downloaded the Smasthag demo app from course's site. Project builds fine (after small changes in Twitter, TwitterRequest etc. classes, because I use the latest Xcode 7b4) and works fine on simulator (I also had to add NSAppTransportSecurity
key to info.plist
), but not on a device - it doesn't fetch tweets . I tested it on both iPhone 6 with iOS 9 Public Beta and iPad 2 with iOS 8.4. Moreover, when app is running in the simulator and I change hashtag to search, whole tableView reloads with new tweets, but in the console I get this:
2015-07-23 03:24:15.560 Smashtag[25991:4344251] _BSMachError: (os/kern) invalid capability (20)
2015-07-23 03:24:15.560 Smashtag[25991:4344251] _BSMachError: (os/kern) invalid name (15)
App仍然运行良好,但是这个错误让我感到困惑。我对谷歌中的这个_BSMachError没什么好处的(只有一条孤独的印尼语推文)。我不知道为什么app不能在设备上获取推文。
App still runs fine, but this error bugs me. I couldn't fine anything about this _BSMachError in google (just one lonely Indonesian tweet). I can't also get why app doesn't fetch tweets on a device.
推荐答案
要解决此问题,您应该设置区域设置到en_US。
To fix this issue you should set locale to en_US.
将Tweet.swift中的私有扩展名asTwitterDate更改为以下内容以解决非en_US设备上的问题。
Change the private extension asTwitterDate in Tweet.swift to the following to fix issue on non en_US devices.
...
private extension String {
var asTwitterDate: NSDate? {
get {
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "EEE MMM dd HH:mm:ss Z yyyy"
dateFormatter.locale = NSLocale(localeIdentifier: "en_US")
let createdAt = dateFormatter.dateFromString(self)
return createdAt
}
}
}
此后,您的应用程序应加载并正确显示所有数据。
After this your application should load and show all data correctly.
这篇关于运行斯坦福的CS193p Smashtag应用程序时_BSMachError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!