函数签名特化 <Arg[0] = Owned To Guaranteed>

function signature specialization <Arg[0] = Owned To Guaranteed>

我有一个带有三个嵌入式 UINavigationControllerUIPageViewController。该应用程序在我的设备上运行完美,但在其他一些测试设备上,我遇到了崩溃:function signature specialization <Arg[0] = Owned To Guaranteed> in Crashlytics。

这是我在 Crashlytics 中收到的报告。

这是我用来设置 UIPageViewController 的代码。

import Foundation
import UIKit
import Parse

class PageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {

    private var pages: [UINavigationController]!

    private var currentPageIndex: Int!

    override func viewDidAppear(animated: Bool) {

        if (FBSDKAccessToken.currentAccessToken() != nil) {


        } else {

            self.performSegueWithIdentifier("toSignup", sender: self)

        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Page view controller is initial VC, but if FB Access Token is nil, redirect to signup flow
        if (FBSDKAccessToken.currentAccessToken() != nil) {

            self.dataSource = self
            self.delegate = self

            self.pages = [
                self.storyboard!.instantiateViewControllerWithIdentifier("DiscoverNav") as! UINavigationController,
                self.storyboard!.instantiateViewControllerWithIdentifier("LiveFeedNav") as! UINavigationController,
                self.storyboard!.instantiateViewControllerWithIdentifier("ProfileNav") as! UINavigationController
            ]

            (self.pages[0].topViewController as! DiscoverViewController).parentPageViewController = self
            (self.pages[1].topViewController as! LiveFeedViewController).parentPageViewController = self
            (self.pages[2].topViewController as! ProfileViewController).parentPageViewController = self


            self.currentPageIndex = 1
            let startingViewController = self.pages[1] as UINavigationController
            self.setViewControllers([startingViewController], direction: .Forward, animated: false, completion: nil)

        } else {

            self.performSegueWithIdentifier("toSignup", sender: self)

        }

    }

    func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {
        let index = (self.pages as NSArray).indexOfObject(viewController)
        self.currentPageIndex = index

        // if currently displaying last view controller, return nil to indicate that there is no next view controller
        return (self.currentPageIndex == self.pages.count - 1 ? nil : self.pages[self.currentPageIndex + 1])
    }

    func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {
        let index = (self.pages as NSArray).indexOfObject(viewController)
        self.currentPageIndex = index

        // if currently displaying first view controller, return nil to indicate that there is no previous view controller
        return (index == 0 ? nil : self.pages[index - 1])
    }



    func displayPageForIndex(index: Int, animated: Bool = true) {
        assert(index >= 0 && index < self.pages.count, "Error: Attempting to display a page for an out of bounds index")

        // nop if index == self.currentPageIndex
        if self.currentPageIndex == index { return }

        if index < self.currentPageIndex {
            self.setViewControllers([self.pages[index]], direction: .Reverse, animated: true, completion: nil)
        } else if index > self.currentPageIndex {
            self.setViewControllers([self.pages[index]], direction: .Forward, animated: true, completion: nil)
        }

        self.currentPageIndex = index
    }

}

现在看来,崩溃似乎来自 ProfileViewController.swift,但是当 UIPageView 加载时,该页面从未调用过任何内容。在 Crashlytics 报告的第 16 和 17 行,它指向 PageViewController。那里似乎没有太多关于此错误的信息,但从我读到的内容来看,它似乎与某处的 nil 值有关。有人可以就此提供建议吗?

PageViewController 的第 47 行指向 self.storyboard!.instantiateViewControllerWithIdentifier("ProfileNav") as! UINavigationController

事实证明,一些测试用户试图从他们的 Gmail 应用程序打开 TestFlight 邀请,显然你不应该这样做。我告诉他们从 Safari 或 Apple Mail 打开,它起作用了。感谢额外的头痛 TestFlight。