ios - 当我在真实设备 iOS 中运行它时应用程序崩溃

标签 ios iphone swift alamofire

当我在 Xcode 8.3 上使用 Alamofire 网络时,我正在开发一个应用程序,当我在模拟器中使用 Alamofire 代码时,它正在工作,但是当我在具有 10.2 iOS 版本的真实设备 iPhone 7 中尝试我的代码时,应用程序停止并获取

fatal error: unexpectedly found nil while unwrapping an Optional value 

还有这个断点异常

libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
    0x101b003d0 <+0>:   stp    x26, x25, [sp, #-0x50]!
    0x101b003d4 <+4>:   stp    x24, x23, [sp, #0x10]
    0x101b003d8 <+8>:   stp    x22, x21, [sp, #0x20]
    0x101b003dc <+12>:  stp    x20, x19, [sp, #0x30]
    0x101b003e0 <+16>:  stp    x29, x30, [sp, #0x40]
    0x101b003e4 <+20>:  add    x29, sp, #0x40            ; =0x40 
    0x101b003e8 <+24>:  mov    x19, x6
    0x101b003ec <+28>:  mov    x20, x5
    0x101b003f0 <+32>:  mov    x21, x4
    0x101b003f4 <+36>:  mov    x22, x3
    0x101b003f8 <+40>:  mov    x23, x2
    0x101b003fc <+44>:  mov    x24, x1
    0x101b00400 <+48>:  mov    x25, x0
    0x101b00404 <+52>:  adr    x8, #0xf11fc              ; protocol descriptor for Swift._DefaultCustomPlaygroundQuickLookable + 136
    0x101b00408 <+56>:  nop    
    0x101b0040c <+60>:  add    x0, x8, #0x10             ; =0x10 
    0x101b00410 <+64>:  mov    w1, #0x28
    0x101b00414 <+68>:  orr    w2, wzr, #0x7
    0x101b00418 <+72>:  bl     0x101b00750               ; swift_rt_swift_allocObject
    0x101b0041c <+76>:  mov    x8, x0
    0x101b00420 <+80>:  stp    x22, x21, [x8, #0x10]
    0x101b00424 <+84>:  strb   w20, [x8, #0x20]
    0x101b00428 <+88>:  str    w19, [x8, #0x24]
    0x101b0042c <+92>:  adr    x3, #0x40440              ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
    0x101b00430 <+96>:  nop    
    0x101b00434 <+100>: mov    x0, x25
    0x101b00438 <+104>: mov    x1, x24
    0x101b0043c <+108>: mov    x2, x23
    0x101b00440 <+112>: mov    x4, x8
    0x101b00444 <+116>: bl     0x1019e14dc               ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
->  0x101b00448 <+120>: brk    #0x1

这是我运行的代码

Alamofire.request(APIKeys().login, method: .post, parameters: ["email" : email , "password"  : password ], encoding: JSONEncoding.default , headers: APIKeys().headers).responseJSON(completionHandler: {( response  ) in
            if response.result.value != nil {
                print(response)
             let json = JSON(response.result.value ?? "")
            if json["status"].intValue  == 200
            {
                UserDefaults().set(json["email"].stringValue, forKey: "email")
                UserDefaults().set(json["id"].intValue, forKey: "userID")


            }


            }


        } )

最佳答案

刚刚清理了缓存并重新安装了应用程序,它在设备上运行良好

关于ios - 当我在真实设备 iOS 中运行它时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43953625/

相关文章:

iOS - 是否可以缓存 CGContextDrawImage?

ios - UISearchBar,去掉右边的 "arrow"

iphone - 如何在 iOS 的 NSURL 字符串中传递多个参数?

ios - 如何通过返回应用程序的链接分享到 Facebook? swift

iOS, swift : play background music and sound effects without delay

ios - 禁用自动隐藏字幕 ios Storyboard

ios - 屏幕突然变白

ios - 如何在 tableView 中选择单元格时触发 pickerview

iphone - 如何通过NSString获取类对象

iphone - nsxml解析器问题