Xcode console debug output

I am loading data from firebase and outputting data to tableView. However, I find that from time to time duplicate content appears in my tableView. Initially, I thought I accidentally inserted the same content into my PostService.ps.posts array. However, after I set a breakpoint just before reloading the tableView, I typed the following command in the console, and the output was strange.

print PostService.ps.posts

As the output below, item [4] and item [6] have {...} which I don’t know what they mean (this is the first time I use the console command for debugging). And in my deskView. I see the data presented in the following sequence [1], [2], [3], [3], [5], [5], [6], [7], [8], [9] for rows from 0 to line 8). Thus, it seems that line 3 (start form 0) receives the same data as line 2, and line 5 receives the same data as line 4. Weird?

I am not sure why this is happening, and I have nothing to start with, because it does not happen every time. I hope that the output of this console will help me to correctly indicate

  [1] = 0x000000012f4849b0 {
    _postKey = "-KQTh_WDO2IS1rYfLgnU"
    _userId = "SpmZmYwD3Td04sQZxOYeALwuMp03"
  }

  [2] = 0x0000000130e61f40 {
    _postKey = "-KQTHnE4IIeBR3tyDM3r"
    _userId = "1isMS98ZmXYrpCmGb4o5voaAqXH2"
    _image = "www.image2.com"
  }

  [3] = 0x0000000130192b40 {
    _postKey = "-KQtN4YG51HOF19FrM8s"
    _userId = "SpmZmYwD3Td04sQZxOYeALwuMp03"
    _image = "www.image3.com"
  }

  [4] = 0x0000000130192b40 {...}

  [5] = 0x0000000130269560 {
    _postKey = "-KR2On6u7dRy0GAvE1Gn"
    _userId = "SpmZmYwD3Td04sQZxOYeALwuMp03"
    _image = "www.image4.com"
  }

  [6] = 0x0000000130269560 {...}

  [7] = 0x000000013150f4c0 {
    _postKey = "-KQThGLVA-MsviGMsXOS"
    _userId = "1isMS98ZmXYrpCmGb4o5voaAqXH2"
    _image = "www.image5.com"
  }

  [8] = 0x000000012fa88890 {
    _postKey = "-KQt269uHGM99oFKuJRt"
    _userId = "SpmZmYwD3Td04sQZxOYeALwuMp03"
    _image = "www.image6.com"
  }

  [9] = 0x000000012f9bcad0 {
    _postKey = "-KQThdCAm-PlCsCnXcBZ"
    _userId = "SpmZmYwD3Td04sQZxOYeALwuMp03"
  }

PostService.ps.posts, [Post] viewForHeaderInSection ( cellForRowAtIndexPath ),

    if let cell = tableView.dequeueReusableHeaderFooterViewWithIdentifier("TableSectionHeader") as? TableSectionHeader {
        let post = PostService.ps.posts[section]
        var image: UIImage?
        if let url = post.imageUrl {
            image = DiscoverVC.imageCache.objectForKey(url) as? UIImage
        }            
        cell.configureCell(post, image: image)
        cell.delegate = self

        return cell

    } else {
        return TableSectionHeader()
    }
+4
3

, , {...}. . , , , {...}. [3] [4] [5] [6] . , , {...}, . . , .

import UIKit

class ViewController: UIViewController {

    class model {
        let first = "first"
        let second = "second"
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        var array = [model]()

        let obj = model()
        let obj1 = model()

        array.append(obj) // original objct
        array.append(obj) // duplicate because classes are referece types
        array.append(obj) // duplicate because classes are referece types
        array.append(obj1) // new Object

        print(array)


    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

:

(lldb) print array
([SampleDebugApp.ViewController.model]) $R0 = 4 values {
  [0] = 0x00007fed8ac93990 (first = "first", second = "second")
  [1] = 0x00007fed8ac93990 {...}
  [2] = 0x00007fed8ac93990 {...}
  [3] = 0x00007fed8ac939d0 (first = "first", second = "second")
}
(lldb)

. . .

+1

, , PostService.ps.posts.

po .

po PostService.ps.posts[section] viewForHeaderInSection, post.

post : po post.imageUrl, po post.postKey, po post.userId

. , . , , , , ().

+2

Xcode , , ;

0
source

Source: https://habr.com/ru/post/1653979/


All Articles