Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3953

Trying to Understand Declare Libraries & Selectors with Cocoa

$
0
0

Although the docs do provide some helpful information when using Declare, I still struggle a bit to understand a few things (specifically with regards to macOS).

As a result, a lot of the time I just copy and paste from either Sam’s AppKit or the macOSLib repo, when I need something not in the Xojo toolkit.

Question: Using Selector respondsToSelector: as an example, it appears this can be called with either Lib “Cocoa” or “Foundation”.

  1. Is this because the “Cocoa” framework encompasses all (or most) libraries in the macOS API? As the Apple literature suggests.

  2. If yes to the above, does that mean calling “Cocoa” routes the Selector request to “Foundation”?

  3. Or does respondsToSelector: exist in both places and is potentially executing slightly different logic?

  4. And if respondsToSelector: exists only in “Framework”, is there a performance difference calling “Cocoa” verses “Foundation” directly? Or something else important I’m missing?

// what's the difference besides what Lib is being called?
Declare Function respondsToSelector Lib "Cocoa" Selector "respondsToSelector:" (obj As Ptr, sel As Ptr) As Boolean
// verses
Declare Function respondsToSelector Lib "Foundation" Selector "respondsToSelector:" (obj As Ptr, sel As Ptr) As Boolean

Note: This post is about expanding my knowledge of Declare, and not about finding a Plugin solution (I already own both MBS & Einhugur).

Thank you.

6 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 3953

Trending Articles