Search code examples
iosapp-storeiphone-privateapi

Is accessing a private property (starting with underscore) using KVC considered using private API?


On a project I'm working on collaboratively, I've seen that my coworker has used the following code to access/modify non-public properties of UISearchBar:

something = [self.searchBar valueForKey:@"_searchField"];
[searchField setValue:grayColor forKeyPath:@"_placeholderLabel.textColor"];
...

I'm not sure if this is considered using private API by Apple. Would these cause App Store rejection? I've seen some questions regarding private API usage, but couldn't find any answer to this exact question.


Solution

  • Ive used what youve described above in numerous apps, all of which never have been rejected. Just keep an eye on it with every new iOS release, just incase things break.

    So in regards to 'Would these cause App Store rejection?', from my experience, no.