iOS Storyboards/NIBs low-level anatomy. How are they implemented?

前端 未结 2 1807
故里飘歌
故里飘歌 2021-01-30 18:56

I became interested in low-level details of NIB/Storyboards mechanisms in iOS. I want to learn more about their implentation - I\'m interested in developing of my own mechanism.

2条回答
  •  灰色年华
    2021-01-30 19:12

    At a very high level (to gloss over a ton of implementation details), Xcode serializes the object graph that you created (the view hierarchy, etc.) using Cocoa's native object persistence mechanism, known as NSCoding.

    NSCoding is a protocol that allows any graph of objects that conform to it to be serialized and saved to disk or transmitted over a network, and then be reconstructed back into the original object graph.

    Of course things like outlets and actions also have to be stored, so there's a bit more to it than just the top-level objects and a bunch of views, but you can think of a xib file as an XML serialization of the view hierarchy you construct in Xcode.

提交回复
热议问题