12

After updating to iOS8.3 I started getting a bunch of new warnings that werent there on iOS8.2. One in particular that caught my eye;

@property (strong, nonatomic) IBOutlet UITableView *tableView;

which was declared in a '.m' file.

What has changed in iOS8.3 to make this a warning?

Auto property synthesis will not synthesize property 'tableView'; it will be implemented by its superclass, use @dynamic to acknowledge intention
DevC
  • 6,982
  • 9
  • 45
  • 80
  • Is your view controller you added the `tableView` to a `UITableViewController`? – Joe Apr 15 '15 at 17:00
  • 3
    FYI, IBOutlets should be weak since the view itself holds a strong reference. Avoid retention cycles. https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html – Mark McCorkle Apr 15 '15 at 17:06
  • 2
    @DCGoD the horrors of looking at code that I wrote 18months ago haha – DevC Apr 16 '15 at 08:26
  • 4
    We are ALL guilty of that, LOL. Cringe, learn, refactor, rinse and repeat. ;-) Code is never "done". – Mark McCorkle Apr 16 '15 at 10:49

4 Answers4

16

If you're using a UITableViewController then tableView is already synthesized. (ie. self.tableView is the tableView of the UITableViewController).

Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
16

I faced similar issue too. I solved this by the following method. Inside your .m file write @dynamic tableView under the @implementation

I hope your issue will be solved.

fozoglu
  • 729
  • 5
  • 21
  • This does not necessarily address the underlying cause, which is that you are overriding a property defined in a superclass. – Tash Pemhiwa May 07 '17 at 20:41
11

What has changed? The compiler has become more clever.

You are probably subclassing UITableViewController.

UITableViewController already has a property named tableView. It is already synthesized or implemented otherwise in UITableViewController. So the warning tells you that you are not getting your own tableView property, but that you are getting the one supplied by UITableViewController.

Obviously if you were not aware of the tableView in UITableViewController, and if you wrongly assumed that this is your property, under your control, there would be trouble. That's why you get a warning. So if that is what you were doing, then your code was always badly broken, and needs fixing.

But if you just have the @property declaration in your code, but you know that it is actually the UITableViewController property, no harm is done, but remove the @property because it is wrong.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • Thanks for the details explanation. It was the last point. It was really old code I was looking at. Thankfully It was brought to my attention. – DevC Apr 16 '15 at 08:37
1

Had a similar problem with a custom UITableViewCell creating a new property called imageView. Since a property named imageView already existed, I kept getting the error message. I simply changed the name to projectImageView and it worked.

NSCoder
  • 1,594
  • 5
  • 25
  • 47