Search code examples
iosobjective-cwatchkitwkinterfacetable

Cannot specify setter 'setTitle:' for properties of NSObject or WKInterfaceController


I am trying to set up a WKInterfaceTable. I followed Apples docs. My Label is not getting text and I get this error message in console:

Cannot specify setter 'setTitle:' for properties of NSObject or WKInterfaceController

How can I fix this? Objective-C please. Here s my code:

.h

#import <Foundation/Foundation.h>
#import <WatchKit/WatchKit.h>

@interface MainRowType : NSObject

@property (strong, nonatomic) IBOutlet WKInterfaceImage *image;
@property (strong, nonatomic) IBOutlet WKInterfaceLabel *title;

@end

.m

#import "MainRowType.h"

@implementation MainRowType


@end

.h

#import <WatchKit/WatchKit.h>
#import <Foundation/Foundation.h>
#import "MainRowType.h"

@interface WatchTableController : WKInterfaceController


@property (strong, nonatomic) IBOutlet WKInterfaceTable *tableView;
@property (strong, nonatomic) NSMutableArray *titleArray;


@end

.m

I call this method

- (void)configureTableWithData:(NSMutableArray*)dataObjects {

    [self.tableView setNumberOfRows:[dataObjects count] withRowType:@"mainRowType"];

    for (NSInteger i = 0; i < self.tableView.numberOfRows; i++) {
        MainRowType* theRow = [self.tableView rowControllerAtIndex:i];
        NSString *titleString = [dataObjects objectAtIndex:i];

        [theRow.title setText:titleString];

    }
}

Thanks


Solution

  • Your title property is the problem. You can't name a property "title" in those classes. Change the property name and you should be all set.