我正在开发一个应用程序,当在Xcode 8.3上使用Alamofire的网络时,当我在模拟器中使用Alamofire代码时它正在工作但是当我在具有10.2 iOS版本的真实设备iPhone 7中尝试我的代码时,应用程序停止并获得< / p>
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")
}
}
} )
答案 0 :(得分:1)
刚刚清理了缓存并重新安装了该应用,它在该设备上运行良好