pro648 / tips Goto Github PK
View Code? Open in Web Editor NEWiOS学习进程中遇到的知识点
iOS学习进程中遇到的知识点
文章在此。
在 Swift 中,对类的成员直接用 &member
是不安全的,Apple 工程师在 Apple Developer 论坛里有提过。
简单来说 Swift 可能会把
class AtomicCounter {
var count: Int32 = 0
func increment() {
OSAtomicAdd32(1, &count)
}
}
展开成
class AtomicCounter {
var count: Int32 = 0
func increment() {
var tmp = count
OSAtomicAdd32(1, &tmp)
count = tmp
}
}
如果改成 os_unfair_lock,就有可能每次传给系统一个临时变量在栈上的地址,而内核是根据内存地址来鉴别锁的。
若要安全使用,必须使用指针(UnsafePointer
家族)手工分配一个地址,初始化,并在 deinit
里记得释放。这样会造成一次额外的内存寻址……之前 Swift 论坛上有标准库的人(@lorentey)在推这个问题的解决方案,但是似乎没有下文了。
该文章中有两点需要指正的地方,以免误导读者。
\w
匹配包括下划线的任何单词字符。等价于 [a-zA-Z0-9_]
。
\W
匹配任何非单词字符。等价于 [^a-zA-Z0-9_]
。
等价表达式中少了下划线(_
)。
请问 show(_, sender:) 与 navigationController?.pushViewController 是什么关系?有什么异同?
提几个小疑问啊。
关于playground中的demo
M做了两件事 1. 数据的转换 2. 给view赋值
感觉数据转换可以直接放在model中,把VM的几个计算属性放到Pet中。 对于给view赋值的操作,我们一般都是直接把model赋值给了view
关于MVVM Pattern
感觉VM的操作也是放到Model中更合适。总感觉VM没有发挥多少它的作用
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.