ios – Swift项目与Thread 1崩溃:EXC_BAD_ACCESS(code = 1,address = 0x0)

我一直在搜索这个问题的解决方案.它看起来像一个坏的内存访问,就像尝试访问一个不存在的对象.我试过使用NSZombie看看有没有出现,据我所知,在应用程序代表的声明中正在崩溃.

AppDelegate.swift

@UIApplicationMain
class AppDelegate: UIResponder,UIApplicationDelegate
{
var window: UIWindow?


func application(application: UIApplication!,didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool
{
    // Override point for customization after app launches
    Parse.setApplicationId("removed on purpose",clientKey: "removed on purpose")
    PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
    PFFacebookUtils.initializeFacebook()

    return true
}

func application(application: UIApplication!,openURL url: NSURL,sourceApplication: String,annotation: AnyObject?) -> Bool
{
    return FBAppCall.handleOpenURL(url,sourceApplication: sourceApplication,withSession: PFFacebookUtils.session())

}

func applicationDidBecomeActive(application: UIApplication!)
{
    FBAppCall.handleDidBecomeActiveWithSession(PFFacebookUtils.session())
}

func applicationWillResignActive(application: UIApplication!)
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks,disable timers,and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication!)
{
    // Use this method to release shared resources,save user data,invalidate timers,and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution,this method is called instead of applicationWillTerminate: when the user quits.

}

func applicationWillEnterForeground(application: UIApplication!)
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationWillTerminate(application: UIApplication!)
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

DashboardViewController.swift

import UIKit

class DashboardViewController: UIViewController
{
override func viewDidLoad()
{
    super.viewDidLoad()
    // Do any additional setup after loading the view
}

override func didReceiveMemoryWarning()
{
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated
}

}

使用断点我已经确定它甚至没有超过应用程序委托的类声明.我尝试检查我的Main.storyboard文件中的所有类,以确保一切都正确连接,再次,我可以告诉它.真的很感激一些关于如何解决这个问题的想法!谢谢!

编辑:我解决了问题,代码现在已经修复了.希望这可以帮助别人,如果他们有类似的问题!

解决方法

今天遇到同样的问题.截至Xcode 6 beta 6,自动完成建议:
func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]) -> Bool {}

启动时,这会在EXC_BAD_ACCESS和空白屏幕中崩溃.

一旦一个!被添加到最后一个参数,一切正常:

func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]!) -> Bool {}

在current documentation!也缺少:

optional func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]) -> Bool

以上是来客网为你收集整理的ios – Swift项目与Thread 1崩溃:EXC_BAD_ACCESS(code = 1,address = 0x0)全部内容,希望文章能够帮你解决ios – Swift项目与Thread 1崩溃:EXC_BAD_ACCESS(code = 1,address = 0x0)所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。