Let's say I have an NSObject Variable that has properties such as Variable.x, Variable.y, Variable.z and I want the program to determine which property is assigned a value and then do it? Is it possible to choose that at runtime? Actually the properties will not be known to the method until it asks for them. So x, y, and z, will not always be the properties. It will have a list of properties available, the object name, and the values to apply to those properties. I don't need to create the properties at runtime (although that would be nice) but I need to look at what is available and assign values to them at runtime. Sorry if this is not detailed enough. I'm mostly self taught and don't use the right terminology sometimes. But this site has saved me a lot of time and aggravation in the past.
Yes, you can do all of this using the Objective-C runtime. See the Objective-C Runtime Reference , especially class_copyPropertyList
, class_getProperty
, objc_setAssociatedObject
and objc_getAssociatedObject
. (There are a few different ways to accomplish what you want.)
Given that information, you should be able to find sample code and ample discussion on Stack Overflow, so I won't elaborate further.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加