Converting Cocoa objects in PyObjC return value to Python objects?

170 Views Asked by At

I'm experimenting with retrieving network scan results from CoreWLAN in Python using PyObjC, with code that looks like:

from CoreWLAN import *
client = CWWiFiClient.sharedWiFiClient()
en0 = client.interface()
scan, _ = en0.scanForNetworksWithSSID_error_(None, None)

This returns an NSSet of CWNetwork objects into scan. I can convert the NSSet into a Python set easily enough, but is there a similarly straightforward way to convert the CWNetwork instances into Python dict or NamedTuple structures?

I only care about data members of the CWNetwork objects, and do not need to be able to pass messages to them again.

Note: the code above depends on an API introduced in OS X 10.10, and will not run on earlier versions of OS X.

0

There are 0 best solutions below