2017-02-02 11 views
2

私はSwiftを初めて使用しています。ObjectMapperを使用してJSONを解析していますが、データをTableViewに表示する必要があります。しかし、私は問題を抱えている:TableView NSException

のlibC++ abi.dylib:タイプNSExceptionのキャッチされない例外で終了

私は方法numberOfRowsInSection後にそれを得ます。コンソールで

let timeStamp = NSNumber(value: Date().timeIntervalSinceNow) 

    var programs = [PrograToDayModel]() 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     super.viewDidLoad() 
     let timeStamp = NSNumber(value: Date().timeIntervalSinceNow) 
     self.downloadPrograms(for: timeStamp) 

    } 

    func downloadPrograms(for timestamp: NSNumber) { 

     Alamofire.request("http://52.50.138.211:8080/ChanelAPI/programs/\(timestamp)").responseArray { (response: DataResponse<[PrograToDayModel]>) in 

      let programlArray = response.result.value 

      if let programlArray = programlArray { 
       for program in programlArray { 

        self.programs.append(program) 
        print(program.title as Any) 
       } 


      } 
      DispatchQueue.main.async { 
       self.tableView.reloadData() 
      } 
     } 
    } 

それ財iプリント要素: enter image description here

私の配列は、配列が、それはJSONを解析するためのそれは私のコード

をなぜ起こったか、私は理解していない 2193個の要素を持っている、nilでありません

テーブルのための私のコード:

// MARK: - Table view data source 

    override func numberOfSections(in tableView: UITableView) -> Int { 
     // #warning Incomplete implementation, return the number of sections 
     return 1 
    } 

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     // #warning Incomplete implementation, return the number of rows 
     print(self.programs.count as Any) 
     return self.programs.count 

    } 


    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "ProgramTableViewCell", for: indexPath) as! ProgramTableViewCell 

     cell.title.text = self.programs[indexPath.row].title 

     return cell 
    } 
} 

すべての識別子の場所で Iのuタブバーを歌う、tableView、tableViewCell どうすればこの問題を解決できますか?

+3

デバッガーに理由があることが必要です。それも共有してください。 –

+2

デバッガには、そのNSExceptionに関する詳細情報が必要です。それは助けになるはずです。 – Larme

+1

@Umair Afzal thats all:警告:Objective-Cクラス情報を読み込めませんでした。これにより利用可能な型情報の品質が大幅に低下します。と私のprintとlibC++ abi.dylib:NSExceptionタイプのキャッチされていない例外で終了します。 –

答えて

2

問題を識別するために、あなたはこれを試すことができます -

それはそうMain.storyboardに行く、との上部にあるビューコントローラを右クリックしてその問題

の理由かもしれません電話の概要を確認し、黄色のフラグが付いているコンセントを取り外します(ある場合)。

enter image description here

+0

いいえ私は決して持っていない –

0

行のセクション/番号を追加しようとしたときuitableviewcontrollerを初期化しようとしたとき、私は同様の非説明的なエラーを取得しました。あなたはtableviewセルクラスを登録しましたか?私はカスタムテーブルビューのセルが作成されているので、このエラーの原因となっているかもしれないテーブルビューに登録されていない場合があります。

tableView.register("ProgramTableViewCell".self, forCellReuseIdentifier: "ProgramTableViewCell")