# Doubt about the runtime system

**URL:** <https://forums.swift.org/t/doubt-about-the-runtime-system/6070>\
**Category:** Using Swift\
**Created:** [June 6, 2017, 1:55pm UTC](https://forums.swift.org/t/doubt-about-the-runtime-system/6070 "2017-06-06T13:55:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronaldo\_Faria\_Lima](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Ronaldo\_Faria\_Lima](https://forums.swift.org/u/Ronaldo_Faria_Lima)\
**Post date:** [June 6, 2017, 1:55pm UTC](https://forums.swift.org/t/doubt-about-the-runtime-system/6070/1 "2017-06-06T13:55:58Z")

</div>

Hi, all.

I´m currently developing a solution that will apply a theme using appearance proxies. The idea is to have a configuration file where the developer will say which class he wants to customize and which properties with its corresponding values.

For instance, let´s say that one want to customize all navigation bar´s tint color property. So, the definitions for it will be put on a plist file as strings like:

UINavigationBar  
&nbsp;&nbsp;&nbsp;&nbsp;tintColor  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#442d5f

To do so, I tried to do something like this:

let aClass: AnyClass? = NSClassFromString(“UINavigationBar")  
let proxy = (aClass as? UIAppearance.Type)?.appearance()  
let sel = NSSelectorFromString("setTintColor:")  
proxy?.perform(sel, with: UIColor.red)

However, doing that way is not secure at all. The /perform/ method may fail if the configured class does not have it. But, testing for the method existence by using /responds(to:)/ always return false.

It is worse if the class being customized is a specialization of some UIKit class. So, this is my question: is there a way to to load a class dynamically and inspect its properties/methods without knowing its type previously like I´m trying to do? I have tried to use a Mirror, but without success.

Thanks,

Ronaldo

---

<div class="post-metadata">

**Author:** ![Brent\_Royal-Gordon](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@Brent\_Royal-Gordon](https://forums.swift.org/u/Brent_Royal-Gordon)\
**Post date:** [June 6, 2017, 6:35pm UTC](https://forums.swift.org/t/doubt-about-the-runtime-system/6070/2 "2017-06-06T18:35:37Z")

</div>

That's odd. Could you use `aClass.instancesRespond(to: sel)` instead?

> **···**
>
> > On Jun 6, 2017, at 6:55 AM, Ronaldo Faria Lima via swift-users \<swift-users@swift.org\> wrote:
> > 
> > The /perform/ method may fail if the configured class does not have it. But, testing for the method existence by using /responds(to:)/ always return false.
> 
> --  
> Brent Royal-Gordon  
> Architechies
