2017-05-05 78 views
0

我想在我的Xcode输出中打印IMDB JSON请求。 无论用户写入搜索栏我想从IMDB获取虚拟小说的JSON请求,然后在Xcode输出中打印。lldb IMDB API错误

我的请求:http://www.omdbapi.com/?t=pulp+fiction 但它给,LLDB错误

Xcode的输出:

2017年5月5日20:13:12.363263 + 0300 IMDB API项目[4327:696994] [MC] systemgroup.com.apple.configurationprofiles的系统组容器 路径为 /Users/gurkan/Library/Developer/CoreSimulator/Devices/7DCF1A18-D92C-45BB-9F89-01EBF200DA41/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationpro文件 2017-05-05 20:13:12.388362 + 0300 IMDB Api Project [4327:696994] [MC] 从私有有效用户设置读取。

点击进入搜索栏后。 (我所著的东西,然后点击,我所著并不重要,因为我只想得到低俗小说任何用户写入到搜索栏现在。)

(LLDB)

那么这屏幕进入。

0_swift_bridgeNonVerbatimFromObjectiveC:

libswiftCore.dylib`_swift_bridgeNonVerbatimFromObjectiveC: 
    0x109ebabd0 <+0>: pushq %rbp 
    0x109ebabd1 <+1>: movq %rsp, %rbp 
    0x109ebabd4 <+4>: pushq %r15 
    0x109ebabd6 <+6>: pushq %r14 
    0x109ebabd8 <+8>: pushq %r12 
    0x109ebabda <+10>: pushq %rbx 
    0x109ebabdb <+11>: movq %rdx, %r14 
    0x109ebabde <+14>: movq %rsi, %r12 
    0x109ebabe1 <+17>: movq %rdi, %r15 
    0x109ebabe4 <+20>: callq 0x109ebaed0    ; tryBridgeNonVerbatimFromObjectiveCUniversal(swift::HeapObject*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*) 
    0x109ebabe9 <+25>: testb %al, %al 
    0x109ebabeb <+27>: je  0x109ebabf6    ; <+38> 
    0x109ebabed <+29>: popq %rbx 
    0x109ebabee <+30>: popq %r12 
    0x109ebabf0 <+32>: popq %r14 
    0x109ebabf2 <+34>: popq %r15 
    0x109ebabf4 <+36>: popq %rbp 
    0x109ebabf5 <+37>: retq 
    0x109ebabf6 <+38>: leaq 0x872bb(%rip), %rsi  ; protocol descriptor for Swift._ObjectiveCBridgeable 
    0x109ebabfd <+45>: movq %r12, %rdi 
    0x109ebac00 <+48>: callq 0x109ee6de0    ; swift_conformsToProtocol 
    0x109ebac05 <+53>: movq %rax, %rbx 
    0x109ebac08 <+56>: testq %rbx, %rbx 
    0x109ebac0b <+59>: je  0x109ebac47    ; <+119> 
    0x109ebac0d <+61>: movq %r12, %rdi 
    0x109ebac10 <+64>: movq %rbx, %rsi 
    0x109ebac13 <+67>: callq *(%rbx) 
    0x109ebac15 <+69>: movq %r15, %rdi 
    0x109ebac18 <+72>: movq %rax, %rsi 
    0x109ebac1b <+75>: callq 0x109eb54f0    ; swift_dynamicCastUnknownClass 
    0x109ebac20 <+80>: testq %rax, %rax 
    0x109ebac23 <+83>: je  0x109ebacb2    ; <+226> 
    0x109ebac29 <+89>: movq 0x10(%rbx), %r9 
    0x109ebac2d <+93>: movq %rax, %rdi 
    0x109ebac30 <+96>: movq %r14, %rsi 
    0x109ebac33 <+99>: movq %r12, %rdx 
    0x109ebac36 <+102>: movq %r12, %rcx 
    0x109ebac39 <+105>: movq %rbx, %r8 
    0x109ebac3c <+108>: popq %rbx 
    0x109ebac3d <+109>: popq %r12 
    0x109ebac3f <+111>: popq %r14 
    0x109ebac41 <+113>: popq %r15 
    0x109ebac43 <+115>: popq %rbp 
    0x109ebac44 <+116>: jmpq *%r9 
    0x109ebac47 <+119>: movq (%r12), %rax 
    0x109ebac4b <+123>: xorl %ecx, %ecx 
    0x109ebac4d <+125>: cmpq $0x7ff, %rax    ; imm = 0x7FF 
    0x109ebac53 <+131>: cmoval %ecx, %eax 
    0x109ebac56 <+134>: cmpl $0xf, %eax 
    0x109ebac59 <+137>: je  0x109ebac96    ; <+198> 
    0x109ebac5b <+139>: cmpl $0xd, %eax 
    0x109ebac5e <+142>: jne 0x109ebacb2    ; <+226> 
    0x109ebac60 <+144>: movq 0x8(%r12), %rax 
    0x109ebac65 <+149>: movq (%rax), %rax 
    0x109ebac68 <+152>: xorl %ecx, %ecx 
    0x109ebac6a <+154>: cmpq $0x7ff, %rax    ; imm = 0x7FF 
    0x109ebac70 <+160>: cmoval %ecx, %eax 
    0x109ebac73 <+163>: cmpl $0x80, %eax 
    0x109ebac78 <+168>: ja  0x109ebac91    ; <+193> 
    0x109ebac7a <+170>: leaq 0x766c7(%rip), %rbx  ; protocol witness table for Swift._BridgeableMetatype : Swift._ObjectiveCBridgeable in Swift 
    0x109ebac81 <+177>: leaq 0x3c(%rip), %rcx   ; <+244> 
    0x109ebac88 <+184>: movslq (%rcx,%rax,4), %rax 
    0x109ebac8c <+188>: addq %rcx, %rax 
    0x109ebac8f <+191>: jmpq *%rax 
    0x109ebac91 <+193>: callq 0x109eb6260    ; swift_unreachable(char const*) 
    0x109ebac96 <+198>: movq 0x10(%r12), %rax 
    0x109ebac9b <+203>: testl $0xffffff, %eax   ; imm = 0xFFFFFF 
    0x109ebaca0 <+208>: jne 0x109ebacb2    ; <+226> 
    0x109ebaca2 <+210>: testl %eax, %eax 
    0x109ebaca4 <+212>: js  0x109ebacb2    ; <+226> 
    0x109ebaca6 <+214>: leaq 0x7669b(%rip), %rbx  ; protocol witness table for Swift._BridgeableMetatype : Swift._ObjectiveCBridgeable in Swift 
    0x109ebacad <+221>: jmp 0x109ebac0d    ; <+61> 
    0x109ebacb2 <+226>: leaq 0x4c3c8(%rip), %rax  ; "value type is not bridged to Objective-C" 
    0x109ebacb9 <+233>: movq %rax, 0xb9268(%rip)  ; gCRAnnotations + 8 
    0x109ebacc0 <+240>: int3 
-> 0x109ebacc1 <+241>: nopl (%rax) 

Main.storyboard: https://i.hizliresim.com/M03v57.png

Viewcontroller.swift:

// 
// ViewController.swift 
// IMDB Api Project 
// 
// Created by gurkan on 5.05.2017. 
// Copyright © 2017 gurkan. All rights reserved. 
// 

import UIKit 

class ViewController: UIViewController,UISearchBarDelegate { 


    @IBOutlet weak var searchBar: UISearchBar! 

    @IBOutlet weak var imageView: UIImageView! 

    @IBOutlet weak var titleLabel: UILabel! 


    @IBOutlet weak var directorLabel: UILabel! 

    @IBOutlet weak var ratingLabel: UILabel! 

    @IBOutlet weak var actorsLabel: UILabel! 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     // Do any additional setup after loading the view, typically from a nib. 

     searchBar.delegate = self 
    } 

    func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { 

     searchForMovie(title: searchBar.text!) 
     searchBar.text = "" 


    } 

    func searchForMovie(title: String){ 

     //http://www.omdbapi.com/?t=pulp+fiction 
     if let movie = title.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed){ 

      let url = URL(string: "http://www.omdbapi.com/?t=pulp+fiction") 
      let session = URLSession.shared 
      let task = session.dataTask(with: url!, completionHandler: { (data, response, error) in 
       if error != nil { 
        print(error!) 
       } else { 

        if data != nil { 

         do { 

          let jsonResult = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! Dictionary<String,String> 


          DispatchQueue.main.async { 
           print(jsonResult) 
          } 

         } catch { 

         } 

        } 

       } 

      }) 

      task.resume() 

     } 

    } 
} 

结果,我怎样才能解决这个LLDB错误?我应该如何打印IMDB JSON请求来制作纸质小说?

的Xcode版本:版本8.3.2 模拟器:iPhone 6(部署目标10.3)

https://i.hizliresim.com/r3o2R7.png

回答

0

你 “逼” 的东西在斯威夫特使用!每次运行崩溃的风险。而且,当你同时发生许多事情时,弄清楚它出错的地方会变得棘手。

试试这样说:

func searchForMovie(title: String) { 

    //http://www.omdbapi.com/?t=pulp+fiction 
    if let movie = title.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) { 

     if let url = URL(string: "https://www.omdbapi.com/?t=pulp+fiction") { 

      let session = URLSession.shared 

      let task = session.dataTask(with: url, completionHandler: { (data, response, error) in 

       if error != nil { 
        print(error!) 
       } else { 

        if let d = data { 

         do { 

          let jsonResult = try JSONSerialization.jsonObject(with: d, options: JSONSerialization.ReadingOptions.mutableContainers) 

          print(jsonResult) 

         } catch { 

         } 

        } 

       } 

      }) 

      task.resume() 

     } 

    } 

} 
+0

太谢谢你了!这是工作。 –

+0

这不是免费的 试试这个 http://www.theimdbapi.org/ – Chali