Skip to Content
Swift游戏开发经典实例
book

Swift游戏开发经典实例

by Jonathon Manning, Paris Buttfield-Addison
January 2020
Intermediate to advanced
356 pages
6h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Swift游戏开发经典实例
性能和调试
333
应用程序能够使用的内存取决于设备;通常,一个
App
可以使用设备内存的
60%
(例
如,如果设备有
2GB
内存,那么它可以使用最多
1.2GB
)。如果某个
App
超出了
该限制,将立即被操作系统终止。
11.4
查找崩溃原因
问题
我们想找出是什么原因导致了应用程序崩溃,并修复它。
解决方案
首先,判断崩溃的类型。崩溃的常见类型包括:
异常导致的崩溃
这通常发生在你的代码做了某些苹果的代码不允许你做的事情,比如向数组中
插入空值。当异常发生时,我们可以在调试控制台中看到调用栈信息。
因内存压力导致的崩溃
如前面所述,
iOS
会强行终止任何超出内存限制的程序。这不是严格意义上的
崩溃,但从用户的角度看,它依然是一种崩溃的类型。当内存不足导致崩溃出
现时,
Xcode
会显示内存警告。
一旦我们知道了崩溃的类型,我们就可以进行修复了。
讨论
修复的方法取决于当前崩溃所属的类型。
修复异常
要修复异常,我们需要找出引发异常的地方。最简单的方法,是在异常发生时触发
一个异常断点,这将在异常发生时中断程序的运行(而不是让异常导致程序崩溃)。
异常断点的添加方法如下:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習

精通機器學習

Aurélien Géron
FreeBSD® Unleashed

FreeBSD® Unleashed

Brian Tiemann, Michael C. Urban
深入淺出代數

深入淺出代數

Tracey Pilone, Dan Pilone
Swift学习手册

Swift学习手册

Jon Manning, Paris Buttfield-Addison, Tim Nugent

Publisher Resources

ISBN: 9787519840129