nsassert

What is NSAssert1?

怎甘沉沦 提交于 2019-12-23 08:46:44
问题 I am developing an application on iOS. I see there is a macro called NSAssert1 . What is it for? What are the differences in usage between NSLog and NSAssert1 ? Please guide me or suggest a tutorial where I can read about it. 回答1: NSAssert variants take a condition and a message. If the condition isn't met/true, then the assertion fails and NSAssert raises an exception with the message provided. For example, NSAssert((a == b), @"Error message"); will raise an exception when a is not equal to

Why does NSAssert break in main instead of in the code that call the assertion

感情迁移 提交于 2019-11-28 09:27:59
问题 I set this NSAssert NSAssert(isStillLoadingArgument== [[self class] stillLoading],@"Hmm.... we think isStill Loading is false or true and yet stillLoading is true");; Here is the screenshot of where I ask this question: Then when assertion fail, the code break here: Which is very annoying because I want to see the assertion break on the code I set up the assertion instead. So, how do I do so. Ben answer unfortunately doesn't solve the issue: 回答1: You need to add a Breakpoint to your project

What's the point of NSAssert, actually?

て烟熏妆下的殇ゞ 提交于 2019-11-27 16:45:33
I have to ask this, because: The only thing I recognize is, that if the assertion fails, the app crashes. Is that the reason why to use NSAssert? Or what else is the benefit of it? And is it right to put an NSAssert just above any assumption I make in code, like a function that should never receive a -1 as param but may a -0.9 or -1.1? Daniel Assert is to make sure a value is what its supposed to be. If an assertion fails that means something went wrong and so the app quits. One reason to use assert would be if you have some function that will not behave or will create very bad side effects if

What's the point of NSAssert, actually?

老子叫甜甜 提交于 2019-11-26 22:29:38
问题 I have to ask this, because: The only thing I recognize is, that if the assertion fails, the app crashes. Is that the reason why to use NSAssert? Or what else is the benefit of it? And is it right to put an NSAssert just above any assumption I make in code, like a function that should never receive a -1 as param but may a -0.9 or -1.1? 回答1: Assert is to make sure a value is what its supposed to be. If an assertion fails that means something went wrong and so the app quits. One reason to use