Debug Expression of objective-c syntax

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.