小编Ger*_*tan的帖子

Xcode 8 beta 4:Calendar.Unit与Calendar.Component

这个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

我做错了什么或这是一个错误?

swift3 xcode8 xcode8-beta4

26
推荐指数
2
解决办法
2万
查看次数

Swift - 从反向地理编码生成地址格式

我试图使用Swift 3中的CLGeocoder生成格式化的完整地址.我引用了这个SO线程来获取下面给出的代码.

但是,有时应用程序崩溃时会出现"nil"错误:

//Address dictionary
print(placeMark.addressDictionary ?? "")
Run Code Online (Sandbox Code Playgroud)

问题:

  1. 如何连接从GeoCoder检索到的这些值以形成完整地址?(街+城+等)
  2. 当func无法找到地址时,如何处理我得到的nil错误?

完整代码:

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)

xcode google-maps reverse-geocoding ios swift

20
推荐指数
4
解决办法
4万
查看次数

在iOS 10 beta 1中,HealthKit授权与未处理的NSException崩溃

使用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)

swift healthkit ios10

10
推荐指数
2
解决办法
2296
查看次数

针对Xcode 7之前项目的Xcode 7 UI测试用例

Apple在Xcode 7中简化了iOS UI测试.

使用新的Xcode 7项目,要获得iOS UI测试的完整配置,您只需在创建项目时选中"包含UI测试".

对于在Xcode 7存在之前创建的项目,在Xcode 7中获得相同的步骤是什么?

ios swift xcode7 xcode-ui-testing

9
推荐指数
1
解决办法
3121
查看次数

链接错误与Xcode 7 beta,地址清理和CocoaPods + adMob

我成功地将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一起工作哪个导致这个?

xcode admob cocoapods address-sanitizer xcode7

6
推荐指数
0
解决办法
499
查看次数

Info.plist可能不包含UIRequiredDeviceCapabilities键

当我尝试使用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

xcode itunesconnect application-loader healthkit

6
推荐指数
1
解决办法
2225
查看次数

HealthKit:保存在iPhone上的锻炼在Activity App中不可见

使用HealthKit,我正在保存

  1. 锻炼
  2. 相应的活性能量样本
  3. 相应的步行/跑步距离样本

我在苹果手表和iPhone上运行相同的代码.

当我在iPhone上保存时

  • 我可以在我的iPhone App中选择锻炼和样品
  • 我可以在iPhone Health App中看到锻炼和样品
  • 锻炼和样品不在 iPhone活动应用程序中(坏)

当我在苹果手表上保存时

  • 我可以在我的iPhone App中选择锻炼和样品
  • 我可以在iPhone Health App中看到锻炼和样品
  • 我可以在iPhone活动应用程序中看到锻炼和样本

当我在苹果手表上保存并在我的iPhone应用程序中删除它

  • 我不能在我的iPhone App中选择锻炼和样品(好)
  • 我无法在iPhone Health App中看到锻炼和样品(好)
  • 直到watchOS 2.1 + iOS 9.2.1:我仍然可以在iPhone活动应用程序中看到锻炼和样本(非常糟糕)
  • 使用watchOS 2.2 beta 5 + iOS 9.3 beta 5测试:锻炼和样本从iPhone上的活动应用程序中删除(好)

当我在Apple Watch上保存并在Apple Watch App中删除它时

  • 使用watchOS 2.2 beta 5 + iOS 9.3 beta 5进行测试:一切都如预期:手表和iPhone上的任何提到的应用程序都不可见/可选(从iOS 9.3开始就好)
  • 直到watchOS 2.1 + iOS 9.2.1:iPhone上没有删除锻炼和样本.(坏到iOS 9.2.1)

我做错了什么,或者这是HealthKit和iPhone Activity App的工作方式吗?

更具体的问题:

  • 如何在iPhone上保存锻炼和样本,以便锻炼和样本不仅可以在同一iPhone上的Health App中看到,还可以在同一iPhone上的Activity App中看到?
  • 如何删除我使用我的Watch App保存的iPhone上的锻炼和样本,这样锻炼和样本不仅可以在同一个iPhone上的Health App中删除,还可以在同一iPhone上的Activity App中删除?

如果这不是我的错误,那么任何iOS应用都无法可靠地保存活动应用中显示的锻炼.iOS应用程序可以将数据发送到手表应用程序,这是一个简单的部分.但我知道无法在后台处理手表上的这些数据.用户必须启动监视应用程序才能处理数据.

测试是在硬件上进行的,而不是在模拟器上进行的.iOS 9.2.1,watchOS 2.1

我使用watchOS 2.2 beta …

iphone ios healthkit apple-watch

6
推荐指数
1
解决办法
1250
查看次数

Xcode 8 beta 6:AnyObject被Any替换:哪里是classForCoder?

xcode的8个β6取代AnyObject通过Any.

在某些情况下,我用于a.classForCoder调试原因,看看它里面有什么.有了AnyObject这个工作.有了Any这不起作用了.

现在我必须使用Any:在类型变量中查看哪种类型的首选方法是什么Any

转换AnyObject似乎不是非常有用,因为在许多情况下这是一个String并且自Xcode 8 beta 6以后String不再确认AnyObject.

swift swift3 xcode8-beta6

5
推荐指数
1
解决办法
1711
查看次数

在ABAP OO中使用包含常量的include

我有一个ABAP包含只包含常量.(不是我的代码)

我想在ABAP OO方法中使用这些常量.(我的代码)

如何在面向对象的ABAP环境中使用这些常量而不复制它们?

我们的想法是只定义一次这些常量.它们已在此包含中定义.

附加问题:是否有可能在公共部分创建一个包含上述常量的类,以便我只进行一次include,并以面向对象的方式从其他类中使用这些常量?

sap abap

5
推荐指数
1
解决办法
1888
查看次数

BitTrex时间格式和时区

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支持,但是由于所有交易所,新客户似乎不知所措。

api rest swift

5
推荐指数
1
解决办法
1804
查看次数