Swift: programmatically enumerate outgoing segues from a UIVIewController

后端 未结 2 1585
-上瘾入骨i
-上瘾入骨i 2020-12-19 16:17

I want to list the outgoing segues from a UIViewController, as described in Programmatically enumerate outgoing Segues for a UIViewController, but in Swift. (Swift 2, Xcode

2条回答
  •  佛祖请我去吃肉
    2020-12-19 16:54

    this valueForKey("storyboardSegueTemplates") is UNDOCUMENTED property and UIStoryboardPresentationSegueTemplate is UNDOCUMENTED class. Beware of rejection from App Store if you are uploading application to App Store.

    If you want to use this in your in-house projects, use as following

    for template in (valueForKey("storyboardSegueTemplates") as? [AnyObject])! {
        if let identifier = template.valueForKey("identifier") as? String {
            print("identifier - " + identifier)
        }
        else {
            print("no identifier for \(template)")
        }
    }
    

    Found from https://github.com/JaviSoto/iOS9-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UIStoryboardSegueTemplate.h

提交回复
热议问题