1解决bug
看一个方法被调用的次数,可以右键,点击Find Call Hiererarchy;
不要背代码,要执行代码,看问题出现在哪里,然后去解决;
Command + R 运行,发现问题,然后结局问题;
写代码要测试,看有没有数据再往下写;
打断点多用PO;
2编码习惯
Sql 语句在数据库里查好了,再往代码里写;
增强代码的可读性:在参数后面换行。如: vc.tabBarItem.selectedImage = UIImage(named:
"tabbar_" + imageName + "_selected")?
.withRenderingMode(.alwaysOriginal);
3代码规范
最重要的方法放在上面,页面的东西放在下面不常改;
代码优化
封装类的方法:看见重复额的代码,抽取出来,见参数就写参数;
能用颜色的不用背景图片;
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme