Error in build when Xcode associated with outlet instead of action in Button

Asked 2 years ago, Updated 2 years ago, 37 views

I'm having trouble with the following 5.

Xcode is version 6.4 and is made with swift.
Running Reset contents and settings... on the iOS simulator does not change much.

If you have any questions, please
a. Why doesn't the build pass when it should go back to the previous state at Cmd+z at 4?
Does it mean that it is not allowed to link with Outlet in Button?
This time I accidentally tied it up, but I wonder if there are times when I want to use the outlet just like the label.

Thank you for your cooperation.

------- Transcribe from comment -----
Error Log

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[setValue: forUndefinedKey:]: this class is not key value coding-component for the key myButton.'

----- That's it -----

9/12 22:48 Add
It seems that there was a link left ↓ MyButton. I deleted this and it worked fine.Maybe the number of cmd*z was not enough...
Enter a description of the image here

ios swift xcode

2022-09-30 16:58

1 Answers

I just touched the MAC, so I will answer based on the image.

a. Why doesn't the build pass when it should go back to the previous state at Cmd+z at 4?

I tried it here, too.
To undo IBOutlet and IBAction changes, you could undo them by Cmd+z on the StoryBoard.
Activating the code pane and Cmd+z does not seem to affect the StoryBoard file.

Does it mean that it is not allowed to link with Button and outlet?

It's not a bad idea at all.
Rather, IBOutlet is a necessary step to match UI parts with code.

That's the solution, but I'll write it as a guess.
Does the XCode log say unrecognized selector sent to instance?

Enter a description of the image here

Let me explain about the image
* UIButton is defined as button in IBOutlet.
* The UIButton Action method defines aaa.

If you start the app in this state and press button, signal SIGABRT will occur.
The logs are as follows:

2015-09-12 10:49:59.041 16535 [1319:25886] ***Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_6535.ViewController onButtonTapped:]:unrecognized selector sent to instance 0x65'fee0fee0fee0f

The reason for the error is that UIButton defines onButtonTapped:, but there is no onButtonTapped: in the ViewController class.

*As shown in the above image, IBAction definitions that do not exist must not remain

Press Ctrl and click on the affected UI part to view the connection list (black pop-up screen) and see if there are any unnecessary connections left.


2022-09-30 16:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.