我正在尝试使用 3D 触摸快速操作,我正在设置它复制 VEA 软件代码。在他的示例代码中,它工作得很好,但是当我尝试将它添加到我的应用程序时,我遇到了一些不寻常的错误。我是编码和快速的新手,所以请尽可能多地解释。谢谢。下面我有我的应用程序委托中的代码。
这是我收到错误的地方(self.window?):
@available(iOS 9.0, *)
func handleShortcutItem(shortcutItem: UIApplicationShortcutItem) -> Bool
{
var handled = false
var window: UIWindow?
guard ShortcutIdentifier(fullType: shortcutItem.type) != nil else { return false }
guard let shortcutType = shortcutItem.type as String? else { return false }
switch (shortcutType)
{
case ShortcutIdentifier.First.type:
handled = true
var window = UIWindow?()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let navVC = storyboard.instantiateViewControllerWithIdentifier("ProjectPage") as! UINavigationController
// Error on line below
self.window?.rootViewController?.presentViewController(navVC, animated: true, completion: …Run Code Online (Sandbox Code Playgroud) 我试图匹配一个以K,P,J和NI开头的字符串.我正在使用以下正则表达式:
^[kpjni](.*)$
Run Code Online (Sandbox Code Playgroud)
但是,它不能按我的意愿工作.它接受任何以N或I开头的字符.我怎么能强制它匹配NI而不是N和我分开.