gpt4 book ai didi

ios - NSAssert 会占用 iOS 设备上的任何内存吗?

转载 作者:行者123 更新时间:2023-11-28 20:10:27 26 4
gpt4 key购买 nike

如果我们在带有 NSLogs 的设备上运行应用程序,那么它可能会在一定程度上降低应用程序的速度。

NSAssert 在内存方面是否与 NSLog 一样?

如有任何意见或建议,我们将不胜感激。

提前谢谢你。

最佳答案

也许这会回答你的问题

It's important to note that as of Xcode 4.2, assertions are turned off by default for release builds, which is accomplished by defining the NS_BLOCK_ASSERTIONS macro. That is to say, when compiled for release, any calls to NSAssert & co. are effectively removed.

来源:http://nshipster.com/nsassertionhandler/

如果您启用它们,那么它们是有代价的(显然它们需要评估)并且根据您让它们执行的代码而有所不同。对于简单的零比较,它可以忽略不计。

如需进一步引用,请参阅:http://www.mikeash.com/pyblog/friday-qa-2013-05-03-proper-use-of-asserts.html

特别是这段话

The runtime cost should be negligible, and if it's not, then you should redo your asserts to fix that.

关于ios - NSAssert 会占用 iOS 设备上的任何内存吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20497581/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com