天道酬勤,学无止境

xcode8-beta3

Timer.scheduledTimer Swift 3 pre-iOS 10 兼容性(Timer.scheduledTimer Swift 3 pre-iOS 10 compatibility)

问题 我需要安排一个计时器来每秒触发一个函数,但我看到在 Xcode 8 beta 3 中,scheduledTimer 仅适用于 iOS 10。 在 iOS 9 或以前的版本中是否有使用计时器的替代方法? Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { (timer) in print("Hi!")}) 回答1 解决了使用 Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.updateTime), userInfo: nil, repeats: true) 回答2 用 swift3 运行一个计时器, var timer: Timer? func startTimer() { if timer == nil { timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(self.loop), userInfo: nil, repeats: true) } } func stopTimer() { if timer != nil { timer?.invalidate() timer = nil }

2021-06-24 21:24:22    分类:技术分享    ios   swift   ios9   ios10   xcode8-beta3

Cannot extract xcode 8 beta 3

I have downloaded it 3 times. Twice in safari and once in chrome. Every time I cannot unarchive it with the default tool, or with Unarchiver. Based on this apple developer thread I tried: $ xar -xf Xcode_8_beta_3\ \(1\).xip Error while extracting archive:(Content): archived-checksum sha1's do not match (No such file or directory) Then: $ cpio -it < Xcode_8_beta_3\ \(1\).xip Content cpio: Truncated input file (needed 4433260676 bytes, only 4433260317 available): Unknown error: -1 I have 25 gigs of free space on my drive with this file present (but if it was a disk space issue why is it saying

2021-06-10 01:47:43    分类:问答    xcode8   xar   xcode8-beta3

Timer.scheduledTimer Swift 3 pre-iOS 10 compatibility

I need to schedule a Timer for firing a function every second but I see that in Xcode 8 beta 3 the scheduledTimer is only available for iOS 10. Is there any alternative for using the timer in iOS 9 or previous versions? Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { (timer) in print("Hi!")})

2021-04-15 01:50:46    分类:问答    ios   swift   ios9   ios10   xcode8-beta3

Xcode 8 Beta 3使用旧版Swift问题(Xcode 8 Beta 3 Use Legacy Swift issue)

问题 我在Xcode 8 Beta 3中有一个Objective-C项目。自更新以来,每当我尝试构建时,都会收到以下错误: 必须为使用Swift的目标正确配置“使用旧版Swift语言版本”(SWIFT_VERSION)。 使用[编辑>转换>转换为当前Swift语法…]菜单选择一个Swift版本,或使用“构建设置”编辑器直接配置构建设置。 有人遇到过这个吗? 由于它是一个Objective-C项目,因此没有用于配置Swift的构建设置。 我还确保没有项目依赖项或CocoaPods使用Swift。 我唯一的解决方案是使用Beta2。关于如何解决此问题的任何想法? 我还应该提到我正在运行OSX 10.12 Beta 2。 回答1 如果您使用的是CocoaPods,并且希望在每次pod install时自动将其修复,则可以将以下几行添加到Podfile的末尾: post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.0' end end end 编辑:如果您使用CocoaPods v1.1.1或更高版本,现在已解决此问题

2021-03-30 11:03:55    分类:技术分享    swift   xcode8   xcode8-beta3

Xcode 8 Beta 3 Use Legacy Swift issue

I have an Objective-C project in Xcode 8 Beta 3. Since updating, whenever I try to build I receive the following error: “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly. Has anyone encountered this? Since it's an Objective-C project there's no build setting to configure Swift. I have also made sure none of the project dependencies or CocoaPods are using Swift. The only

2021-03-23 05:36:06    分类:问答    swift   xcode8   xcode8-beta3