Search code examples
objective-cswiftreflectionswift-extensions

Swift read private property from a .m file


I have a library that is written in Objective-C and using .m and .h files.

Is it possible for me to write an extension method for that class and get access to a private property that is only defined in the .m file and not defined in the .h file?

I have tried with the .valueForKey but I only get

payload_data_0
payload_data_1
payload_data_2
instance_type

which all are of type Builtin.RawPointer.


Solution

  • No. The only way for you to access it is to define it publicly in the header.