What is the significance of #pragma marks? Why do we need #pragma marks?

前端 未结 7 1381
耶瑟儿~
耶瑟儿~ 2021-01-29 17:21

What is the purpose of #pragma marks in Xcode? Does their location in .m files matter? Should some #pragma come before all others?

相关标签:
7条回答
  • 2021-01-29 18:21

    When we have a big/lengthy class say more than couple 100 lines of code we can't see everything on Monitor screen, hence we can't see overview (also called document items) of our class. Sometime we want to see overview of our class; its all methods, constants, properties etc at a glance. You can press Ctrl+6 in XCode to see overview of your class. You'll get a pop-up kind of Window aka Jump Bar.

    By default, this jump bar doesn't have any buckets/sections. It's just one long list. (Though we can just start typing when jump Bar appears and it will search among jump bar items). Here comes the need of pragma mark

    If you want to create sections in your Jump Bar then you can use pragma marks with relevant description. Now refer snapshot attached in question. There 'View lifeCycle' and 'A section dedicated ..' are sections created by pragma marks

    0 讨论(0)
提交回复
热议问题