Xcode and additional frameworks

In the Related frameworks and libraries section, there is the Required or Optional option .

Can someone explain the situation in which and how to work with the additional structure? I could hypothetically see a situation where I have some test data and IF infrastructure is enabled. I would like to include some functionality, and if it is not included, then perhaps I would not do anything ...

But otherwise, I don’t understand when you want to use the optional framework

(sample code would be awesome if one exists)

+4
source share
1 answer

Additional binding is useful if you are targeting older versions of the OS where a specific structure may not be available. In this case, you can set the binding of this structure to optional, and this will lead to the program crashing at startup if dlopenit cannot find the data framework.

Then in your code, you can put defensive statements around using this structure to avoid b / c failing to use unresolved characters:

 if (MyWeakLinkedFunction != NULL)
 {
     result = MyWeakLinkedFunction(); // this function comes from a weakly/optionally linked framework
 }

See: Frames and Loose Link

+9
source

Source: https://habr.com/ru/post/1610938/


All Articles