2017-05-05 16 views
0

내 Xcode 출력에 IMDB JSON 요청을 인쇄하려고합니다. 사용자가 검색 창에 글을 쓸 때 나는 IMDB에서 펄프 픽션에 대한 JSON 요청을 받고 싶습니다. 그런 다음 Xcode 출력으로 인쇄하십시오.lldb IMDB API의 오류

내 요청 : http://www.omdbapi.com/?t=pulp+fiction 하지만 준다 lldb 오류

엑스 코드 출력 :

2017년 5월 5일 20 : 13 : 12.363263 + 0300 IMDB API 광고 프로젝트 [4327 : 696994] [MC] systemgroup.com.apple.configurationprofiles의 시스템 그룹 컨테이너 경로는 /사용자/gurkan/라이브러리/개발자/CoreSimulator/장치/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] 개인 유효 사용자 설정에서 읽음.

검색 창에 입력을 클릭하십시오. (나는 무언가를 writed 난 그냥 지금 검색 창하는 어떤 사용자가 쓰기 펄프 픽션 얻을 싶기 때문에 제가 writed하는 것은 중요하지 않다, 클릭.)

(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 요청을 인쇄하려면 어떻게해야합니까?

엑스 코드 버전 : 버전 8.3.2 시뮬레이터 : 아이폰 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