Q:

Swift ios relational picker views and apple dev guidelines

Right now I have a picker view that shows up when you press a label, and after you have selected anything from the picker view and hit done it will hide and the label will change to the value you selected.
But I want to implement another picker view, and that picker view will only display based on the value you selected in the first picker view.
So more or less like a relational dropdown  that you can find on almost every website.
I want to be able to select category and subcategory. But its only about 10% of the categories that has an subcategory thats why I want to build it this way.
So my question now is if this will be against apples dev/design guidelines?
Or does anybody else have a good solution on how to display a category/subcategory selector for a search form in an iOS app?
Thanks in advance,  

A:

Just a rough sketch:
Say you pick a category from you PickerView. Your PickerView should then notify you parent ViewController that the user has picked a Category. The most convenient way to do this is to have a Delegate method, like:
self.delegate.userPickedCategory(pickedCategory: Category)

Now, I assume you Category object contains an array of subcategories:
class Category: NSObject {

var title: NSString!
var subCategories: NSMutableArray!
//some variable containing categories content
}

Say you named the button to your Sub Category Menu subCategoryButton. You should always set hidden = true or at least userInteractionEnabled = false, because you don't know whether the picked category has a sub. 
If your parent ViewController receives the delegate method that your user picked a category, you might do:
    func userPickedCategory(pickedCategory: Category) {
          if pickedCategory.subcategories != nil || pickedCategory.subCategories.count != 0 {
          //you now know the picked category has a subCategory
          //so allow the user to pick that subCategory by enabling this button
          self.subCategoryButton.hidden = false
          self.subCategoryButton.userInteractionEnabled = true
    }

Then, you need to make sure the subCategoryButton shows another picker view containing the subCategories of your picked Category 

