0

Hi I am loading nib file for uitableview cell in swift.

I am registering cell but for that want to use nil ReusableCellWithIdentifier.

Because I don't want to reuse cell.

In objective -C we can pass nil value in ReusableCellWithIdentifier to stop reusing cell but how to do in Swift .

If I am using init for custom cell then other outlets are coming nil and getting fatal Error.

PROBLEM IS IF I AM USING DEQUEREUSEABLE WITH IDENTIFIER LIKE "CUSTOMECELL" THEN IF I CHAGE ANY CELL PROPERTY THEN IT IS REFLECTING IN OTHER CELL ALSO DUE TO REUSE IDENTIFIER.

Mayur Mehta
  • 99
  • 1
  • 9
  • Please show us your code – Luca Angeletti Jul 14 '16 at 12:40
  • If you do not want to reuse the cells then do not register your cell. Just create a new cell in your `cellForRowAtIndexPath` like: `let cell = UITableViewCell.init(style: .Default, reuseIdentifier: nil)` – Santosh Jul 14 '16 at 13:14
  • If I am passing nil I am already getting fatal error while accessing outlet property. – Mayur Mehta Jul 14 '16 at 13:23
  • *...THEN IT IS REFLECTING IN OTHER CELL* looks like misuse of the Model-View-Controller pattern. I recommend to solve that issue. Don't manipulate the view, manipulate the model and let the OS reload the view. – vadian Jul 14 '16 at 14:23

1 Answers1

0

Actually problem was while reusing identifier it was not maintaining state for other cell and I also want to reuse the cell because I am loading from nib.

So for each cell I need to maintain state in Array or dictionary.

Mayur Mehta
  • 99
  • 1
  • 9