Swift 3.0 怎么玩

Swift 已经发展到 3.0,早在几个月前苹果就已经表明 Swift 3.0 还将会有不少崩坏性的改动,这篇博客就来介绍一下新版本 Swift 的主要改动。 编译器与语法 参数标签 在 Swift 3.0 中的函数、方法,从第一个参数开始就必须指定参数标签,当然,你可以使用 _ 明确指出调用时省略参数。 func sum(left: Int, right: Int) -> Int { return left + right } sum(left: 1, right: 2) // 在以往的版本中你可能是这样调用的: // sum(1,2) // sum(1, right: 2)...

OS X: Simulating mouse input programmatically

玩过远程辅助工具小伙伴应该都对模拟鼠标事件不陌生, 要做到这件事, 可以使用 Quartz Event Services。 先来一个 Demo, 首先要引入 ApplicationServices: #include <ApplicationServices/ApplicationServices.h> 接下来, 要模拟事件, 首先需要创建事件: CGPoint p1 = CGPointMake(500, 500); CGPoint p2 = CGPointMake(700, 700); // Move to p1 CGEventRef move1 = CGEventCrea...

Sierra: 找回消失的允许“任何来源”的应用

自从 Sierra 之后, 系统偏好设置 -> 通用 -> 允许以下位置下载的应用 中的 任何来源 便消失了。 为了找回它,我们打开 终端, 输入: sudo spctl --master-disable 回车,输入密码,之后重新打开设置便可以看到久违的 任何来源 了。这个操作也可以解决一些来自网络的应用提示 已损坏 的问题。...

It's amazing how nice people are to you when they know you're going away.

Xcode 8: 注释快捷键失效的问题

Xcode 8 发布以来,Beta 版有一个可能不是很普遍的问题: 注释快捷键 ⌘ + / 失效。 在 Twitter 上找到一个解决办法,很简单,在终端执行下面的指令,然后重启系统即可。 sudo /usr/libexec/xpccachectl ...

User-Agents

一些常见的 User-Agents 示例: 桌面 IE Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Mozilla/4.0 (compatible; MSIE 5.0; Windows NT) 其中,版本号是 MSIE 之后的数字。 如: MSIE 8.0 代表 IE8; Windows NT 6.1 对应操作系统 Windows...

CocoaPods: Swift Version

最近使用 CocoaPods 又出了点问题,在执行 pod trunk push 的时候,出现了 Xcode Build 错误,提示了一些关于 Swift 版本的错误。 起初尝试了配置 Xcode 项目中 Use Legacy Swift Language Version 选项,没有作用。于是更新了 CocoaPods 到最新的测试版本 1.1.0,因为新版中允许指定 Swift 版本,有两种方法: 通过 --swift-version VERSION 来指定 通过 .swift-version 文件来指定,你可以用 echo "VERSION" > .swift-version 创建...

iOS: Easy cast with _ObjectiveCBridgeable

Swift is out there for about a year and it’s a great programming language. I think that almost every iOS/OSX developer out there has already written couple of things in Swift (if you haven’t, go ahead and try, you won’t regret it, I promise). Although, we have many years of libs and frameworks built...

iOS: UIAlertController text alignment

Custom text alignment of UIAlertController: let controller = UIAlertController(title: t, message: informative, preferredStyle: type) let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = alignment paragraphStyle.lineBreakMode = lineBreakMode let messageText = NSMutableAttribute...

Difference between nullable, __nullable and _Nullable in Objective-C

From the Swift blog: This feature was first released in Xcode 6.3 with the keywords __nullable and __nonnull. Due to potential conflicts with third-party libraries, we’ve changed them in Xcode 7 to the _Nullable and _Nonnull you see here. However, for compatibility with Xcode 6.3 we’ve predefined m...
SVG to Data URI Conventer

OS X: Menu Bar Extra is invisible in macOS Dark Mode

周末提交的 APP 又被秒拒, 理由很简单, “Menu Bar Extra is invisible in macOS Dark Mode”, 菜单栏图标在黑色模式中看不到。 由于是第一次用黑白色的图标, 提交之前完全没有考虑到这个问题, 怎么解决呢? 其实很简单。 首先我想到的第一件事是监听, 先试了 NSScreenColorSpaceDidChangeNotification 不起作用, 后来找到了另一个通知: [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(upd...

What's this?

The Night-City version of Hotodogo inspired by Cyberpunk 2077. Not finished yet.

Pinned Message

The Founder and CEO of Infeca Technology.

Developer, Designer, Blogger.

Big fan of Apple, Love of colour.

Feel free to contact me.

反曲点科技创始人和首席执行官。

开发、设计与写作皆为所长。

热爱苹果、钟情色彩。

随时恭候 垂询

Outer Square Inner Square