Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Loading framework variables (aka constants) from pyObjC for arbitrary frameworks
from Foundation import NSBundle
# Load the framework bundle by its identifier
Metadata_bundle = NSBundle.bundleWithIdentifier_("")
# Can also use: bundleWithPath or bundleWithURL
# Load the variable aka constant from the framework into globals
# This says to load whatever "kMDSPreferencesName" is and the type should be "an NSObject" aka "figure it out"
# which ends up giving us a NSString which pyObjC bridges to a python string nicely
objc.loadBundleVariables(Metadata_bundle, globals(), [('kMDSPreferencesName', '@')])
# >>> kMDSPreferencesName
# u''
# OMG wasn't that soooo much easier than using ctypes?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.