ChenYilong / ChenYilong/iOSInterviewQuestions

21题“不推荐在 init 方法中使用点语法”

Open
#75 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
9.5k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

在提到“不推荐在 init 方法中使用点语法”之后,说了原因之后举了个例子:
>在基类 Person 的默认初始化方法中,可能会将姓氏设为空字符串。此时若使用点语法( self.lastName )也即 setter 设置方法,那么调用将会是子类的设置方法

经过测试,运行代码`[[Person alloc] init]`并不会调用子类的setter方法,而是会输出`🔴类名与方法名:-[Person setLastName:](在第25行),描述:根本不会调用这个方法`,请查证。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.