Main.m
1 #import<Foundation/Foundation.h>2 #import "TestClass.h"3 4 intMainintargcConst Char*argv[]) {5 @autoreleasepool {6NSString *purposeinfo =@"the information obtained is useful not only in debug, but also in selector.";7 [TestClass testdebugkeyword:purposeinfo];8 }9 return 0;Ten}
TestClass.h
1 #import <Foundation/Foundation.h>23@interface testclass:nsobject 4 + (void) Testdebugkeyword: (NSString *) purposeinfo; 5 6 @end
Testclass.m
1 #import "TestClass.h"2 3 @implementationTestClass4 5+ (void) Testdebugkeyword: (NSString *) Purposeinfo {6Nsmutablestring *mstrinfo =[[Nsmutablestring alloc] initwithstring:purposeinfo];7[Mstrinfo appendString:@"\n\ndebug some system reserved definition words are used as follows: \ n"];8[Mstrinfo AppendFormat:@"__func__:%s\n", __func__];9[Mstrinfo AppendFormat:@"__pretty_function__:%s\n", __pretty_function__];Ten[Mstrinfo AppendFormat:@"__line__:%d\n", __line__]; One[Mstrinfo AppendFormat:@"__file__:%s\n", __file__]; A -[Mstrinfo appendString:@"\n\ndebug Some core foundation methods use the following: \ n"]; -[Mstrinfo AppendFormat:@"Nsstringfromselector (_cmd):%@\n", Nsstringfromselector (_cmd)]; the[Mstrinfo AppendFormat:@"Nsstringfromclass ([Self class]):%@\n", Nsstringfromclass ([selfclass])]; -[Mstrinfo AppendFormat:@"[[NSString stringwithutf8string:__file__] lastpathcomponent]:%@\n", [[NSString stringwithutf8string:__file__] lastpathcomponent]; - -NSLog (@"%@", mstrinfo); + } - + @end
Results:
1 -- .- - One: -:16.353ocdebugkeyword[465:18859the information obtained is useful not only in debug, but also in selector.2 3 Some system reservation definition words are used when debugging:4__FUNC__: +[TestClass Testdebugkeyword:]5__PRETTY_FUNCTION__: +[TestClass Testdebugkeyword:]6__LINE__: -7__FILE__:/users/kenmu/documents/iosdevelopment/ocdebugkeyword/ocdebugkeyword/TESTCLASS.M8 9 Ten Some of the core foundation methods used in debug are as follows: One Nsstringfromselector (_cmd): Testdebugkeyword: ANsstringfromclass ([Selfclass]): TestClass -[[NSString stringwithutf8string:__file__] lastpathcomponent]: TESTCLASS.M
Debug Expression of objective-c syntax