这个Swift 3代码一直工作到XCode 8 beta 3:
let calendar = Calendar.current
let anchorComponents = calendar.components([Calendar.Unit.day, Calendar.Unit.month, Calendar.Unit.year, Calendar.Unit.hour], from: self)
Run Code Online (Sandbox Code Playgroud)
在Xcode 8中,beta 4 Calendar.Unit似乎被重命名为Calendar.Component.
现在这段代码
let calendar = Calendar.current
let anchorComponents = calendar.components([Calendar.Component.day, Calendar.Component.month, Calendar.Component.year, Calendar.Component.hour], from: self)
Run Code Online (Sandbox Code Playgroud)
产生编译错误 cannot convert value of type Calendar.Component to NSCalendar.Unit
我做错了什么或这是一个错误?
我试图使用Swift 3中的CLGeocoder生成格式化的完整地址.我引用了这个SO线程来获取下面给出的代码.
但是,有时应用程序崩溃时会出现"nil"错误:
//Address dictionary
print(placeMark.addressDictionary ?? "")
Run Code Online (Sandbox Code Playgroud)
问题:
完整代码:
func getAddress() -> String {
var address: String = ""
let geoCoder = CLGeocoder()
let location = CLLocation(latitude: selectedLat, longitude: selectedLon)
//selectedLat and selectedLon are double values set by the app in a previous process
geoCoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) -> Void in
// Place details
var placeMark: CLPlacemark!
placeMark = placemarks?[0]
// Address dictionary
//print(placeMark.addressDictionary ?? "")
// Location name
if let locationName = placeMark.addressDictionary!["Name"] …Run Code Online (Sandbox Code Playgroud) 使用iOS 10,第一个测试版,HealthKit授权崩溃.使用iOS 9.x运行的代码(除了我改为Swift 3)
即使是最简单的授权崩溃:
func authorizeHealthKit(_ completion: ((success:Bool, error:NSError?) -> Void)!)
{
// 1. Set the types you want to read from HK Store
var healthKitTypesToRead: Set<HKObjectType> = Set<HKObjectType>()
healthKitTypesToRead.insert(HKObjectType.characteristicType(forIdentifier: HKCharacteristicTypeIdentifier.dateOfBirth)!)
// 2. Set the types you want to write to HK Store
var healthKitTypesToWrite: Set<HKSampleType> = Set<HKSampleType>()
// 3. If the store is not available (for instance, iPad) return an error and don't go on.
if !HKHealthStore.isHealthDataAvailable()
{
// do some error handling
return;
}
// 4. Request …Run Code Online (Sandbox Code Playgroud) Apple在Xcode 7中简化了iOS UI测试.
使用新的Xcode 7项目,要获得iOS UI测试的完整配置,您只需在创建项目时选中"包含UI测试".
对于在Xcode 7存在之前创建的项目,在Xcode 7中获得相同的步骤是什么?
我成功地将iOS项目转换为Xcode 7 beta + Swift 2(它运行并且测试工作).
但是,当我打开新的Address Sanitizer(选项+运行 - >运行 - >诊断 - >启用地址清理程序时,我从链接器收到以下消息:
Undefined symbols for architecture x86_64:
"___asan_init_v5", referenced from:
_asan.module_ctor in libPods.a(Pods-dummy.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
似乎引用了我用于adMob pod的CocoaPods.我将CocoaPods本身更新为最新版本,并将adMob Pod更新为最新版本.
任何提示如何让Address Sanitizer与CocoaPods或AdMob CocoaPod一起工作哪个导致这个?
当我尝试使用Application Loader将我的iOS + Apple Watch应用程序上传到iTunes时,收到错误消息
ERROR ITMS-90595:"不支持的密钥.捆绑的Info.plist Watchless.app/Watch/WatchlessWatchApp.app/PlugIns/WatchlessWatchApp Extension.appex可能不包含UIRequiredDeviceCapabilities密钥."
Info.plist包含
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>healthkit</string>
</array>
Run Code Online (Sandbox Code Playgroud)
我认为绝对必要,因为监视应用程序和iOS应用程序都严重依赖于HealthKit.
当我打开手表扩展目标的HealthKit功能时,会生成该条目.
我想知道要改变什么.
使用XCode 7.2,Application Loader 3.4
使用HealthKit,我正在保存
我在苹果手表和iPhone上运行相同的代码.
当我在iPhone上保存时
当我在苹果手表上保存时
当我在苹果手表上保存并在我的iPhone应用程序中删除它
当我在Apple Watch上保存并在Apple Watch App中删除它时
题
我做错了什么,或者这是HealthKit和iPhone Activity App的工作方式吗?
更具体的问题:
如果这不是我的错误,那么任何iOS应用都无法可靠地保存活动应用中显示的锻炼.iOS应用程序可以将数据发送到手表应用程序,这是一个简单的部分.但我知道无法在后台处理手表上的这些数据.用户必须启动监视应用程序才能处理数据.
测试是在硬件上进行的,而不是在模拟器上进行的.iOS 9.2.1,watchOS 2.1
我使用watchOS 2.2 beta …
xcode的8个β6取代AnyObject通过Any.
在某些情况下,我用于a.classForCoder调试原因,看看它里面有什么.有了AnyObject这个工作.有了Any这不起作用了.
现在我必须使用Any:在类型变量中查看哪种类型的首选方法是什么Any?
转换AnyObject似乎不是非常有用,因为在许多情况下这是一个String并且自Xcode 8 beta 6以后String不再确认AnyObject.
我有一个ABAP包含只包含常量.(不是我的代码)
我想在ABAP OO方法中使用这些常量.(我的代码)
如何在面向对象的ABAP环境中使用这些常量而不复制它们?
我们的想法是只定义一次这些常量.它们已在此包含中定义.
附加问题:是否有可能在公共部分创建一个包含上述常量的类,以便我只进行一次include,并以面向对象的方式从其他类中使用这些常量?
BitTrex API使用哪种时间格式/时区?
我在文档https://bittrex.com/home/api中找不到答案
示例数据:https ://bittrex.com/api/v1.1/public/getmarkets中的“已创建”
对于其他加密货币市场,我可以使用如下代码:
let isoDateFormater = ISO8601DateFormatter()
var created: Date?
if let isoTimeString = row["Created"] as? String {
created = isoDateFormater.date(from: isoTimeString)
}
Run Code Online (Sandbox Code Playgroud)
哪个不适用于BitTrex:
isoTimeString设置正确,created由于格式不是ISO ,因此
保持为零。
虽然我很容易猜出一个工作日期格式化程序,但我也不得不猜出时区。是否有明确的文档说明BitTrex的API使用哪个时区?
我不需要答案中的快速代码,一个描述就足够了。
编辑 我也问过BitTrex支持,但是由于所有交易所,新客户似乎不知所措。
swift ×5
healthkit ×3
ios ×3
xcode ×3
swift3 ×2
xcode7 ×2
abap ×1
admob ×1
api ×1
apple-watch ×1
cocoapods ×1
google-maps ×1
ios10 ×1
iphone ×1
rest ×1
sap ×1
xcode8 ×1
xcode8-beta4 ×1
xcode8-beta6 ×1