0

Question was answered in the comments below

I have an array of objects and a property of the objects keep changing. I want to set a watchpoint on that specific property in a few elements of the array. Is that possible?

I have seen this answer on how to set watch points in swift, however setting a watchpoint on the array doesn't stop the debugger when an element of that array changes. it doesn't even stop if an element is added to the array

Thanks for the help!

Clarification: I am looking for changes to a particular element of the Array

Clarification: Based on the comments below, I realized the array is irrelevant to the question. I guess a better question would be, how do I set a watchpoint on a property of an object?

user1807157
  • 101
  • 2
  • 9
  • What exactly are you trying to break on? Arbitrary changes in the array, or changes to a particular element in the array? – Alexander May 25 '18 at 17:03
  • changes to a particular element of the Array – user1807157 May 25 '18 at 21:21
  • Add breakpoints inside the methods you care about on that element's type. Then, to make sure you're only breaking on changes to that particular element, right click the breakpoint and make it conditional. Make it check something like `self.id == 123`, or some other attribute(s) that uniquely identify the element. – Alexander May 25 '18 at 21:29
  • The thing is, I cant figure out exactly when the array is changing, and finding every spot that it is potentially changing is quite tedious. I have been doing what you had recommended. I was able to figure out the problem, but I'm wondering if there is a better option in the future – user1807157 May 28 '18 at 16:00
  • If you care about changes to a single element in the array, I don't see why the array is part of the problem. It's irrelevant, no? I don't quite understand the issue – Alexander May 28 '18 at 16:13
  • i guess your right. Now i realize the array is irrelevant. the question should be setting a watch point on a property of an object – user1807157 May 30 '18 at 15:23
  • 1
    You can add a `didSet` block to the property, and put the breakpoint in there. Then, you can make the breakpoint conditional on the value of some uniquely-identifying property of the object of interest, so that it only breaks on the desired object. – Alexander May 30 '18 at 16:33

0 Answers0