Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined symbols for architecture i386: "_OBJC_IVAR_$_UIViewController._view", referenced from:

I've been looking through countless posts about this error:

Undefined symbols for architecture i386:
  "_OBJC_IVAR_$_UIViewController._view", referenced from:
      -[ViewController viewDidLoad] in ViewController.o

ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I already checked .m file and link libraries and copy bundle file. i am using xcode 4.6.2 version. i want to make programmatically Button in ViewDidLoad.

like image 543
Sultania Avatar asked Apr 30 '13 09:04

Sultania


2 Answers

There is uncertainty for the exact reason but there may be many reasons for this error:

  1. Either the button isn't instantiated (allocated & initialized) i.e. button is nil.

  2. If you have made button globally then access it using self

Ex:

myButton = [[UIButton alloc] init];// Don't use like this
self.myButton = [[UIButton alloc] init];// Use like this

EDIT : replace your code with this

self.button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.button.frame = CGRectMake(10, 220, 150, 30);
[self.button setTitle:@"Show" forState:UIControlStateNormal];
[self.button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
[_view addSubview:self.button]; // Note if you have set property of _view then use it as self.view because it also may be the cause of error.

Hope it helps you.

like image 114
Nishant Tyagi Avatar answered Nov 19 '22 03:11

Nishant Tyagi


are you referencing self.view by using _view notation? that could be the problem. try switching out _view for self.view

like image 3
Katushai Avatar answered Nov 19 '22 05:11

Katushai