What is NSAssert1?

I am developing an application on iOS. I see that there is a macro called NSAssert1 . What is this for? What are the usage differences between NSLog and NSAssert1 ?

I ask you to advise or offer a textbook in which I can read about it.

+7
source share
3 answers
-one
source
Options

NSAssert accept the condition and the message. If the condition is not fulfilled / true, then the statement fails, and NSAssert throws an exception with the message provided. For example, NSAssert((a == b), @"Error message"); will throw an exception if a not equal to b . NSAssert1 is an option that takes an additional argument and inserts it into the provided format string: NSAssert1((a == b), @"Error message: %@", someErrorString);

NSLog just write something on the console.

The documentation for all of these macros is on the Apple Developer site .

+28
source

NSAssert , NSParameterAssert , NSAssert1 , and friends are approval macros. Statements are checks of conditions that scream when something is wrong:

 - (void) doSomethingWithPointer: (Foo*) foo { NSAssert(foo != NULL, @"The Foo pointer must not be NULL!"); foo->something; } 

For more information, see the β€œapproval” tags here in the Stack Overflow section.

+5
source

All Articles