惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
Vercel News
Vercel News
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
Help Net Security
Help Net Security
月光博客
月光博客
N
News and Events Feed by Topic
Cloudbric
Cloudbric
博客园 - 司徒正美
L
LangChain Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tenable Blog
The Register - Security
The Register - Security
The Hacker News
The Hacker News
I
InfoQ
The Last Watchdog
The Last Watchdog
MyScale Blog
MyScale Blog
Schneier on Security
Schneier on Security
WordPress大学
WordPress大学
小众软件
小众软件
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
K
Kaspersky official blog
L
LINUX DO - 热门话题
N
News | PayPal Newsroom
F
Fortinet All Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security @ Cisco Blogs
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
Google Online Security Blog
Google Online Security Blog
S
Schneier on Security
C
Cisco Blogs
N
News and Events Feed by Topic
V2EX - 技术
V2EX - 技术
Latest news
Latest news
PCI Perspectives
PCI Perspectives
T
The Blog of Author Tim Ferriss
P
Palo Alto Networks Blog
T
Tor Project blog
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Webroot Blog
Webroot Blog
Attack and Defense Labs
Attack and Defense Labs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

ZDDHUB

PixelsMeasure 开发第二年总结 PixelsMeasure 开发一年总结 Swift/SwiftUI 踩坑记 为什么说 GPT 利好程序员 ChatGPT 编程实现 Web 数字水印 Web 数字水印探究 Micro Frontends for Mobile URL 加载系统(URL Loading System) Protocol Buffers GraphQL 从 0 到 1 开发一款 IOS 应用 - Swift MV* 软件设计架构 学习一个新技巧需要多久? 不停机数据库迁移 Rspec 如何 mock update 方法更新自己? Rails 使用 mysql2 出现的段错误 使用 Docker-compose 部署 Rails 应用到生产环境 独孤九剑 Dit (0x05) - 终端篇 Gem-based Jekyll theme 开发小记 Miscellaneous 前端手记 TodoMVC 之 Redux 篇 前端手记 TodoMVC 之 Server 篇 前端手记 TodoMVC 之 React 篇 前端手记 TodoMVC 之 CSS 篇 独孤九剑 Dit (0x04) - 测试篇 独孤九剑 Dit (0x03) - 缓存篇 英语小抄 LLDB debug Golang Make mistakes 大牛俱乐部上线啦 独孤九剑 Dit (0x02) - 数据结构篇 独孤九剑 Dit (0x01) - 总决 独孤九剑 Dit (0x00) - 我为什么要做 Dit 零值强制类型转换的使用 终端颜色输出重定向 Go语法简略 - 正则表达式 Makefile Go语法简略 - Duck框架探索 Go语法简略 - 依赖注入 Go语法简略 - web应用框架 Go语法简略 - 反射 Go语法简略 - 面向对象 Go语法简略 - goroutine Go语法简略 - 方法和接口 Go语法简略 - 基础篇 大牛 轻松科研 未来这几年 为 Android Studio 创建图标 Shell Git Vim 金庸答百问 论拖延症 Flex, A fast scanner generator 有理想的人 从虚拟到现实 常用视频转接口 Recognizer configuration on CentOS 整个世界清静了 《Python源码剖析》读书笔记
Cocoa troubleshooting
zddhub · 2018-01-14 · via ZDDHUB

心心念念的《Cocoa Programming for OSX (5th edition)》终于回来了,很开心的看了一章。概念和 QT 很像, connection 更像。结果一动手,就被第一个例子给难住了。怎么都调试不通过,浪费了很多时间。写一篇博客记录 Coco 相关问题及解决办法。

1. Failed to connect (textField) outlet from (NSApplication) to (NSTextField)

将 xib 的 Custom Class 设置为自定义的 WindowController 后, connect File’s Owner 到 View 出错:

2018-01-14 10:12:57.380823+0800 GeneratePassword[31997:2465061] Failed to connect (textField) outlet from (NSApplication) to (NSTextField): missing setter or instance variable
2018-01-14 10:12:57.380957+0800 GeneratePassword[31997:2465061] Could not connect action, target class NSApplication does not respond to -generatePasswordWithSender:

解决办法: 添加 NSObject 到 xib,给 NSObject 配置自定义 WindoController,connect NSObject 到 View。

English Version: From the Library, drag an NSObject to the your XIB Document window. Disconnect the objects you’ve connected to File’s Owner by connecting them to the NSObject. Rename the NSObject a suiting one. Highlight NSObject, go to the Inspector. Under Class Identity, search for the name of the NSObject you have just renamed. Save!

2. Xcode cannot resolve the entered keypath

binding

Now the little grey exclamation mark means that Xcode cannot resolve the entered keypath.

The debugger says that this class is not key value coding-compliant for the key text.

命令行报的错误为:

2018-08-07 00:53:44.810844+0800 RaiseMan[33049:2022883] [<RaiseMan.Document 0x6000000c3f70> valueForUndefinedKey:]: this class is not key value coding-compliant for the key employees.

修复方法:

class Document: NSDocument {
    @objc dynamic var employees: [Employee] = []
    // ...
}
  • @objc means you want your Swift code (class, method, property, etc.) to be visible from Objective-C.
  • dynamic means you want to use Objective-C dynamic dispatch.

3. [copyWithZone:]: unrecognized selector sent to instance

详细错误信息:

2018-09-12 21:46:59.056535+0800 RanchForecast[15781:7159803] -[RanchForecast.Course copyWithZone:]: unrecognized selector sent to instance 0x60800025d400

根据错误描述,RanchForecast.Course class 缺少 copyWithZone 方法,所以按以下方法实现了一个

func copy(with zone: NSZone? = nil) -> Any {
    return Course(title: title, url: url, nextStartDate: nextStartDate)
}

运行结果依然错误,错误描述也一样。再想想,copyWithZoneNSCopying 协议需要的方法,实现协议时,需要继承自协议, 编译成功。

class Course: NSObject, NSCopying {
    ...

    func copy(with zone: NSZone? = nil) -> Any {
        return Course(title: title, url: url, nextStartDate: nextStartDate)
    }
}

如果你喜欢这篇文章,欢迎赞赏作者以示鼓励