我的代码一旦尝试请求访问就崩溃了CNContactStore.如果这是一个beta问题,有什么想法吗?
var addressBookStore = CNContactStore()
addressBookStore.requestAccess(for: .contacts) { (granted, error)
Run Code Online (Sandbox Code Playgroud)
在
//此控制台消息在崩溃时被触发 - Messenger [836:1175155] [access] private
崩溃发生在这条线上甚至无法打印错误!
提前致谢
昨晚下载了xcode 8.2 beta,转换了我的大部分代码,但现在我遇到了关于app delegate的六个函数的黄色警告符号:
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. …Run Code Online (Sandbox Code Playgroud) 我正在运行Xcode 8 beta 5.我的应用程序有一个手表扩展.我无法将iPhone模拟器与手表模拟器配对.我已按照配对说明(Xcode,Window,Devices)但没有列出手表模拟器,当我选择任何iPhone模拟器时也没有列出.我尝试过添加模拟器的变体,但我只获得了更多的iPhone模拟器 - 我从未看过手表模拟器或配对.手表模拟器存在 - 我可以启动模拟器,但它没有配对.我试过删除Xcode并重新安装.与beta 4相同的问题.
当我在设备中选择iPhone模拟器时,如何让手表模拟器出现?
更新:要清楚,这些是Apple关于"将Apple Watch Simulator与iPhone模拟器配对"的说明(https://developer.apple.com/library/ios/recipes/xcode_help-devices_organizer/PairingWatchestoiPhoneSimulators/PairingWatchestoiPhoneSimulators.html)
在Simulators下的Devices窗口中,选择iPhone 5及更高版本的模拟器.
在Paired Watches表下,单击Add按钮(+).
我从未看过"配对手表",因此没有添加按钮.
我确实在Xcode 7中看到了这样的:
更新2:
在Xcode 8 beta 6中,"配对手表"表出现在"设备"窗口中,但配对仍然失败,并且"模拟器未配对"对话框.
目前我正在iOS10中测试我当前的版本.我正在使用Xcode 8 beta 6进行测试.这里的Quicklook/QLPreviewController委托方法没有调用.此代码集已与XCode 7和iOS 9.3版本一起使用.我在Apple Developer论坛中检查了这个问题.但找不到答案.有谁解决了这个问题?(我使用的是Objective-C)
如何在XCode 8(iOS 10)中使用Quicklook/QLPreviewController ?
// ----------------- iOS 10解决方案(预览器作为子视图)-------------------
将预览器添加为子视图时会发生此问题.然后我们主要在iOS 9.3及以下版本中使用下面的代码行.
[self addChildViewController:previewer];
self.view addSubview:previewer.view];
[previewer didMoveToParentViewController:self];
Run Code Online (Sandbox Code Playgroud)
在iOS 10问题是由于下面的代码行.
[self addChildViewController:previewer];
Run Code Online (Sandbox Code Playgroud)
对于iOS 10,我们需要检查版本并添加上面的代码行.下面是工作代码集.
QLPreviewController* previewer = [[QLPreviewController alloc] init];
previewer.dataSource = self;
previewer.delegate = self;
// To avoid iOS 10 previewer issue.
if (SYSTEM_VERSION_LESS_THAN(@"10.0")) {
[self addChildViewController:previewer];
}
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;
previewer.view.frame = CGRectMake(0, 102, width, height-300);
[self.view addSubview:previewer.view];
[previewer didMoveToParentViewController:self];
Run Code Online (Sandbox Code Playgroud) 更新到Xcode 8,在iOS 8模拟器中运行我的应用程序崩溃,虽然iOS9和iOS10没问题.
"dyld:懒符号绑定失败:未找到符号:_objc_unsafeClaimAutoreleasedReturnValue引自:**预期在:/ Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 8.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libobjc.A名为.dylib
dyld:未找到符号:_objc_unsafeClaimAutoreleasedReturnValue引
自:**预期在:/ Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 8.1.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libobjc.A.dylib"
我刚刚将我的Xcode ver从7.3更新到8.0,并且一些按钮边框消失了.
代码看起来很好,所以我真的不知道层发生了什么.顺便说一句 - 在其他一些控制器中我可以看到图层边框.
self.button.layer.borderColor = borderColor.CGColor;
self.button.layer.borderWidth = 2;
self.button.layer.cornerRadius = CGRectGetHeight(self.button.frame) / 2;
Run Code Online (Sandbox Code Playgroud)
之前:(图像只是例如 - 边框实时看起来不同)
现在:
我查看了Apple的:
Xcode 8发行说明:https:
//developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
从Swift 2.2迁移到Swift 2.3或Swift 3
https://swift.org/migration-guide/
在macOS 10.12,iOS 10.0,tvOS 10.0和watchOS 3.0中的核心数据有什么新功能
https://developer.apple.com/library/content/releasenotes/General/WhatNewCoreData2016/ReleaseNotes.html#//apple_ref/doc/uid/ TP40017342-CH1-DontLinkElementID_1
还有很多其他......但是,应该从Apple的核心数据编程指南中获得的一个文档尚未从Swift 2更新
.https://developer.apple.com/library/content/documentation/Cocoa/概念/ CoreData/FetchingObjects.html#// apple_ref/DOC/UID/TP40001075-CH6-SW1
理想情况下,我正在寻找类似这样的东西,但对于Swift 3.
https://www.raywenderlich.com/115695/getting-started-with-core-data-tutorial
任何线索都会非常感激.
每个汤姆的评论(下面)我错过了什么步骤?
1)创建一个新项目"测试"
2)选择使用CoreDate(这会创建Test.xcdatamodeld)
这将使用以下内容自动填充AppDelegate(删除默认注释):
func applicationWillTerminate(_ application: UIApplication) {
self.saveContext()
}
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "Test")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
func saveContext () {
let context = persistentContainer.viewContext
if …Run Code Online (Sandbox Code Playgroud) 在swift 3转换后,我遇到了这个错误.
'NSInvalidArgumentException',原因:' - [_ SwiftValue nsli_superitem]:无法识别的选择器发送到实例0x600000a54820'
有问题的代码就是这个,它可以与swift 2一起使用:
let views = ["newView": userLabel]
let widthConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:[newView(0)]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views)
userMainLabel.addConstraints(widthConstraints)
Run Code Online (Sandbox Code Playgroud) 我只是一个初学者,并尝试在我的应用程序中实现推送通知,但没有得到任何适当的指南.主要问题是我没有程序员会员资格.如果可以在没有实际会员资格的情况下进行,请以清晰直接的方式解释.
xcode8 ×10
ios ×8
swift3 ×4
swift ×3
xcode ×3
ios10 ×2
appdelegate ×1
apple-watch ×1
core-data ×1
font-size ×1
iphone ×1
objective-c ×1
quicklook ×1
uibutton ×1