Oscar Apeland
Oscar Apeland

Reputation: 6662

"Duplicate symbols" linker error for no apparent reason

I am seeing Duplicate symbols when linking my project. I have no idea what this means, nor how to fix it, so any help would be greatly appreciated.

since shipNameText seems to be the source of the error, here is where I use it: in .h:

@property (strong,nonatomic)IBOutlet  UILabel *shipNameText;

in .m

@interface boatInfoViewController ()

@end

@implementation boatInfoViewController
@synthesize shipNameText, shipSizeText;


- (void)viewDidLoad
{
    [super viewDidLoad];
    NSUserDefaults *shipName = [NSUserDefaults standardUserDefaults];
    NSUserDefaults *shipSize = [NSUserDefaults standardUserDefaults];
    NSString *name = [[NSUserDefaults standardUserDefaults]
                                 objectForKey:@"shipName"];
    NSString *size = [[NSUserDefaults standardUserDefaults]
                      objectForKey:@"shipSize"];
    shipNameText.text = name;
    shipSizeText.text = size;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

enter image description here

Upvotes: 3

Views: 1222

Answers (2)

Martin R
Martin R

Reputation: 540105

This happens if you import the implementation file "boatInfoViewController.m" instead of the interface file "boatInfoViewController.h", because "boatInfoViewController.m" is then compiled twice.

Upvotes: 6

Hermann Klecker
Hermann Klecker

Reputation: 14068

You have got an ivar declared twice. Its name is shipNameText and it is declared in boatInfoViewController and somewhere else. Do you use 'local' ivars by simply declaring somewhere between @implementation and @end?

Upvotes: 2

Related Questions