Reputation: 251
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.
Upvotes: 5
Views: 3341
Reputation: 846
Are you sure that you are using the
_viewYour.doSomething
not
_view.doSomething
I made this mistake just now.
Upvotes: 0
Reputation: 1520
are you referencing self.view by using _view notation? that could be the problem. try switching out _view for self.view
Upvotes: 3
Reputation: 9913
There is uncertainty for the exact reason but there may be many reasons for this error:
Either the button isn't instantiated (allocated & initialized) i.e. button is nil.
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.
Upvotes: 12