Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Bryan Krossley
1,644 Points@IBAction & @IBOutlet
Hi, I have a @IBAction from a UIButton with a sender: I also have @IBOutlet fronm the same button. Why does this cause an error?
Bryan Krossley
1,644 PointsI will as soon as I get home this evening.
Thanks
12 Answers
Taylor Smith
iOS Development Techdegree Graduate 14,153 Pointswhatever you name it shouldn't matter, as long as you are properly referring to them throughout your code...it's really more for your own organization and not confusing them.
as far as your code is concerned...I'm novice myself...so I couldn't help much there. haha! I'm glad you figured it out though!
Taylor Smith
iOS Development Techdegree Graduate 14,153 Pointswithout seeing your code, are you naming the action and the outlet different names? If it's the same, then that would cause an error
Bryan Krossley
1,644 PointsTaylor, They do have different names for example the name for the IBAction is orangeBtnPushed and the IBOutlet is orangedBtnPressed. I'm new to iOS bevelopment and the Interaction builder.
Thanks
Taylor Smith
iOS Development Techdegree Graduate 14,153 Pointsare you getting this error:
https://teamtreehouse.com/forum/what-does-thread-1-signal-sigabrt-mean ?
Bryan Krossley
1,644 PointsI think that is it. I'll check when I get home to be sure. I will say this that I am pretty sure that the connection and name correctly because I have deleted them and redone them to make sure. But I do have the IBAction and IBOutlet named differently on the same button.
Taylor Smith
iOS Development Techdegree Graduate 14,153 Pointsinteresting..ok..well let us know when you get home!
Bryan Krossley
1,644 Pointsvar buttonSender = UIButton()
@IBOutlet weak var orangeBtnPicked: UIButton!
@IBAction func startGame() {
firstButtonPressed()
}
func firstButtonPressed(){
// var firstButton = randomNumber.randomNumberGen
var firstButton = 0
switch firstButton{
case 0:
orangeBtnPicked.alpha = 1
case 1:
purpleBtnPicked.alpha = 1
case 2:
redBtnPicked.alpha = 1
case 3:
blueBtnPicked.alpha = 1
case 4:
greenBtnPicked.alpha = 1
case 5:
yellowBtnPicked.alpha = 1
default:
7
}
var timer = NSTimer.scheduledTimerWithTimeInterval(0.7, target: self, selector: "alphaSetting", userInfo: nil, repeats: false)
}
@IBAction func orangeBtnPressed(sender: UIButton) {
buttonSender = sender
sender.alpha = 1
var timer = NSTimer.scheduledTimerWithTimeInterval(0.7, target: self, selector: "alphaSetting", userInfo: nil, repeats: false)
}
func alphaSetting(){
if buttonSender.selected == true{
buttonSender.alpha = 0.5
}
else {
orangeBtnPicked.alpha = 0.5
}
}
Taylor Smith
iOS Development Techdegree Graduate 14,153 Pointswhat error are you receiving?
Bryan Krossley
1,644 PointsI might have figured it out. I took a closer look at the connection with IB and it was trying to use touch up outside instead of inside.
Taylor, I sure there is better ways to write the code than what I used but should the IBAction and IBAction work ok if they have different names? Any suggestions would be welcomed.
Thanks
Bryan Krossley
1,644 PointsTaylor, Is there anyway to see what is going on in IB behind the scenes?
Thanks
Taylor Smith
iOS Development Techdegree Graduate 14,153 PointsThe only thing I can think of is if you right click (or ctrl click) your button, it will give you the IB connections you've made, giving you options to change them, delete them, etc. other than that I have no clue! lol
Bryan Krossley
1,644 PointsThank you for your help.
Bryan
obey me
1,135 Pointsobey me
1,135 Pointscan you put up the code for us to help you ..