Can I programmatically set an objects property in iOS?

Bill3

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.

Aaron Brager

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]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I programmatically create a list of objects of the leaflet icon class?

分類Dev

iOS - How to set a UISwitch programmatically

分類Dev

How do I set textalignment property to right in uiwebview in IOS?

分類Dev

How Can I check Property file path is set properly or not

分類Dev

How can I set the TARGET.dir property in Scons?

分類Dev

How can I check if the array of objects has duplicate property values and get the last value that is repeated?

分類Dev

How can I programmatically segue with tapping on an Image?

分類Dev

How can I programmatically register a file with Redmine?

分類Dev

How can I programmatically cause a delay in Android?

分類Dev

How can I change ImageButton size programmatically?

分類Dev

In a Xamarin forms application on Mac OS Visual Studio, how can I set the iOS build level?

分類Dev

how can i set the Tag value For multiple buttons in a single Cell in tableView in ios

分類Dev

Can't set selected item in radiobuttonlist control programmatically

分類Dev

How can we programmatically detect which iOS version is device running on?

分類Dev

Change <item> property programmatically

分類Dev

Can I change multiplier property for NSLayoutConstraint?

分類Dev

How can I safely retrieve this property of this object?

分類Dev

Can I add the Model function property in the API?

分類Dev

Why I can not get property of object ReactJs

分類Dev

How Can I change the property of components of React?

分類Dev

How can I bind property in a static class?

分類Dev

How Can I Create A Custom Property Type

分類Dev

How can I append a string to an object property?

分類Dev

How can I find the Id property or properties related to a navigational property?

分類Dev

How can I bind a Polygon Fill property to the Background property of the button?

分類Dev

How can I programmatically tell if a filename matches a shell glob pattern?

分類Dev

How can I enable or disable the GPS programmatically on Android?

分類Dev

Can I skip file validation when programmatically opening a workbook?

分類Dev

Can I skip file validation when programmatically opening a workbook?

Related 関連記事

  1. 1

    How can I programmatically create a list of objects of the leaflet icon class?

  2. 2

    iOS - How to set a UISwitch programmatically

  3. 3

    How do I set textalignment property to right in uiwebview in IOS?

  4. 4

    How Can I check Property file path is set properly or not

  5. 5

    How can I set the TARGET.dir property in Scons?

  6. 6

    How can I check if the array of objects has duplicate property values and get the last value that is repeated?

  7. 7

    How can I programmatically segue with tapping on an Image?

  8. 8

    How can I programmatically register a file with Redmine?

  9. 9

    How can I programmatically cause a delay in Android?

  10. 10

    How can I change ImageButton size programmatically?

  11. 11

    In a Xamarin forms application on Mac OS Visual Studio, how can I set the iOS build level?

  12. 12

    how can i set the Tag value For multiple buttons in a single Cell in tableView in ios

  13. 13

    Can't set selected item in radiobuttonlist control programmatically

  14. 14

    How can we programmatically detect which iOS version is device running on?

  15. 15

    Change <item> property programmatically

  16. 16

    Can I change multiplier property for NSLayoutConstraint?

  17. 17

    How can I safely retrieve this property of this object?

  18. 18

    Can I add the Model function property in the API?

  19. 19

    Why I can not get property of object ReactJs

  20. 20

    How Can I change the property of components of React?

  21. 21

    How can I bind property in a static class?

  22. 22

    How Can I Create A Custom Property Type

  23. 23

    How can I append a string to an object property?

  24. 24

    How can I find the Id property or properties related to a navigational property?

  25. 25

    How can I bind a Polygon Fill property to the Background property of the button?

  26. 26

    How can I programmatically tell if a filename matches a shell glob pattern?

  27. 27

    How can I enable or disable the GPS programmatically on Android?

  28. 28

    Can I skip file validation when programmatically opening a workbook?

  29. 29

    Can I skip file validation when programmatically opening a workbook?

ホットタグ

アーカイブ