Swift手册第61页的Swift文档提示可以使用where
常规条件连接可选绑定.然而,当我这样做时,我有一个警告,建议我where
用以下代码中的逗号替换:
if let geocodingError = error as? NSError where geocodingError.code == 2
Run Code Online (Sandbox Code Playgroud) 当我在Xcode Version 8.0 beta 4(8S188o)上编译我的代码时,我遇到了这个错误,导致编译失败:
命令/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc失败,退出代码为1
我试图清理项目并擦除派生文件夹,但这并没有改变.它是什么,我怎么能知道更多呢?
当我尝试在终端上编译时,报告的错误是:
无效的bitcast \n%.asUnsubstituted = bitcast%swift.error*%13到i2,!dbg!438 \nLLVM错误:找到损坏的函数,编译中止!\n
你好,
我有一段时间使用自动管理签名选项.然而,当我在最近的Xcode 8.0版本中这样做时,它迫使我使用开发人员代码签名身份甚至在Build Settings中发布和分发,这本身就很奇怪.当我提交相对二进制文件时,我会收到来自Apple的可怕的Missing Push Notification Entitlement电子邮件.为了弥补这一点,我禁用了自动选项并手动返回指定配置文件,这使我可以在分发版本设置中保留分发配置文件,并保存Apple的警告电子邮件.
为什么自动管理以这种方式工作以及如何调整其行为?
我试图为特定目标排除Swift文件的某些部分.然而,我没有找到#ifndef objective-c指令的替代品,而且如果我使用这种形式:
#if taxi_coops
func pippo(){
println("pippo");
}
#else
func triggerActiveLocationUpdate(entering:Bool){}
#endif
Run Code Online (Sandbox Code Playgroud)
预处理器完全忽略该指令并尝试编译triggerActiveLocationUpdate.请注意#if taxi_coops指令在同一文件的其他部分中受到尊重.
有没有办法简单地在Swift中排除一些代码和/或为什么我的修复不起作用?
我正在尝试将我的应用程序移植到iOS 10,包括MPMediaPickerController
通过以下代码可视化:
@IBAction func handleBrowserTapped(_ sender: AnyObject){
let pickerController = MPMediaPickerController(mediaTypes: .music)
pickerController.prompt = NSLocalizedString("Add pieces to queue", comment:"");
pickerController.allowsPickingMultipleItems=true;
pickerController.delegate=MPMusicPlayerControllerSingleton.sharedController();
self.present(pickerController, animated:true, completion:{
MPMusicPlayerControllerSingleton.sharedController().storeQueue()
})
}
Run Code Online (Sandbox Code Playgroud)
然而,屏幕上显示的全部是白色屏幕,没有后退按钮或其他,与以前的iOS版本不同.该块被调用,因此选择器的呈现似乎成功.可能是什么问题呢?
在运行我的应用程序时,我偶尔会遇到这个崩溃似乎与我的代码没有任何关系.它是什么以及我如何避免它?
线程0名:调度队列:com.apple.main线程线程0毁损:0 libsystem_kernel.dylib 0x000000018fc4c16c mach_msg_trap + 8 1 libsystem_kernel.dylib
0x000000018fc4bfdc mach_msg + 72 2 AudioToolbox
0x0000000193c8bcdc ASClient_AudioSessionSetActiveWithFlags + 132 3
AudioToolbox 0x0000000193c6c7f4 AudioSessionSetActive_Priv + 360 4 AVFAudio
0x00000001aa46bf8c - [AVAudioSession setActive:withOptions:error:] + 84 5 Jam Session 0x00000001000d41b8 0x1000b0000 + 147896 6 Jam Session 0x00000001000d53fc 0x1000b0000 + 152572 7 UIKit
0x0000000196ae90ec - [UIViewController loadViewIfRequired] + 1056 8
UIKit 0x0000000196ba2cdc - [UINavigationController _layoutViewController:] + 72 9 UIKit 0x0000000196ba2bb4 - [UINavigationController _updateScrollViewFromViewController:toViewController:] + 416 10 UIKit 0x0000000196ba1efc - [UINavigationController _startTransition:fromViewController:toViewController:] + 140 11 …
Hullo,我开始将我的应用程序移植到iOS 8,我很快就陷入了CLLocationManager的问题.基本上,应用程序不再将地图集中在用户的位置上,而是提出错误:
尝试在不提示位置授权的情况下启动MapKit位置更新.必须首先调用 - [CLLocationManager requestWhenInUseAuthorization]或 - [CLLocationManager requestAlwaysAuthorization].
执行
[CLLocationManager requestAlwaysAuthorization]
Run Code Online (Sandbox Code Playgroud)
什么都不做,甚至NSLocationAlwaysUsageDescription
在应用程序的Info.plist中插入
密钥几乎没有变化.实际上,操作的唯一明显效果是首选项中的位置设置,在运行应用程序时,其值已从我输入的值重置.
我试图迭代字典,以修剪未经证实的条目.以下Objective-C代码的Swift 3转换不起作用:
[[self sharingDictionary] enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {
SharingElement* element=[[self sharingDictionary] objectForKey:key];
if (!element.confirmed){
dispatch_async(dispatch_get_main_queue(), ^{
[element deleteMe];
});
[[self sharingDictionary] performSelector:@selector(removeObjectForKey:) withObject:key
afterDelay:.2];
} else{
element.confirmed=NO;
}];
Run Code Online (Sandbox Code Playgroud)
所以我尝试以这种方式使用以下紧凑的enumerated()方法:
for (key, element) in self.sharingDictionary.enumerated(){
if (!element.confirmed){
element.deleteMe()
self.perform(#selector(self.removeSharingInArray(key:)), with:key, afterDelay:0.2);
} else{
element.confirmed=false
}
}
Run Code Online (Sandbox Code Playgroud)
然而,编译器在处理变量'element'的使用时报告以下错误:
元组类型的值'(键:Int,值:SharingElement)'没有成员'确认'
就像'元素'占据了完整的元组父亲而不是其能力的一部分.是使用enumerated()或在字典处理中的问题,我该如何解决?
我得到这个崩溃报告,我无法通过符号表示我的代码中的行:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'Invalid parameter not satisfying: isfinite(coefficient)'
Run Code Online (Sandbox Code Playgroud)
我在代码中搜索了函数isfinite和variable系数,当然我没有找到.崩溃归因于iPhone6,1上的System 7.1.2
可能有什么决定呢?
ios ×5
xcode ×3
swift ×2
swift3 ×2
account ×1
compilation ×1
crash ×1
dictionary ×1
entitlements ×1
enumerate ×1
ifndef ×1
ios10 ×1
ios8 ×1
iphone ×1
optional ×1
submission ×1
where ×1
xcode4 ×1
xcode7.1beta ×1
xcode8 ×1