2

So i am going through this really old code of Swift 2 and i am fixing bugs in a certain module.

Now this module has a UITableView Cell and the person that worked on it has used Autoresizing on 10 labels inside the UITableViewCell.xib file and they are layed out randomly overalapped on each other. (yeah, big pain in the neck !)

Now, the frame of all the labels is being set out programatically, so I have no idea which frame is being set out for which label.

And the outlets of all the labels are not even named properly so i dont know which label contains the date, which contains the title, which contains the url and so on.Their outlets are named like label1,label2...label10.

My question is that, when i debug the view how do i found out the outlet which is connected to a specific label ?

Hope anybody cud help ?

Zahurafzal Mirza
  • 290
  • 1
  • 15
  • Your outlets would be connected to the text displayed correct? – Rakesha Shastri Oct 26 '18 at 06:19
  • Yes they would be connected. I know the text the labels are displaying but i dont know in which label is displaying what. Like i dont know that "Title" is displayed in label1, label2 or label3 or label10. I want to know if thers a way where the view debugger will allow us to view the connected outlets of respective labels, so that i can know that oh yeah label1 is displaying title, label2 is dispalying date, label5 is display name and so on. – Zahurafzal Mirza Oct 26 '18 at 06:21
  • `label1.text = "Something"` ? – Rakesha Shastri Oct 26 '18 at 06:23
  • I don't quite get you. Why do you debug? Don't you have the source code (xib/storyboard file)? – Andreas Oetjen Oct 26 '18 at 07:15
  • I have the code and everything! i know which outlet is connected to which label in code ! but see they are all placed on top of each other in the UIView File. So its like i can differentiate in the UIView file. But the values to those labels are being set from a for loop. So i dont know which label is getting which value. I tried my best printing the label description but the description doesnt print the label's outlet. ! it sucks sometimes – Zahurafzal Mirza Nov 02 '18 at 07:12

1 Answers1

0

open the xib file of your tableView Cell, then on the right top of Xcode there are 2 circles hugging each other , when u hover it a tooltip shows up "Show the Assistant Editor" click on that, so you can see both your tableVieCell class and xib file, hover over each outlets gray circle in your class ( I mean the circle which is shown in between number of each code's line) so the related label in xib file will light up

Mahgolsadat Fathi
  • 3,107
  • 4
  • 16
  • 34
  • 1
    I know what your trying to say but this isnt what i am looking for ! I know which is connected to which in code. ! But they are all jumbled up and its a mess as its really old code which i am trying to fix. I want to find out the outlets real time while i am debugging the view. – Zahurafzal Mirza Nov 02 '18 at 07:10
  • how many outlets are there? why don't you just remove them all, and add them again with proper names, or even add them in a collection outlet – Mahgolsadat Fathi Nov 03 '18 at 08:05