Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 386789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:36:37+00:00 2026-05-12T15:36:37+00:00

My question may be a bit stupid, but why can’t any object instantiated in

  • 0

My question may be a bit stupid, but why can’t any object instantiated in IB handle, say, button click? I mean I’m able to add my own object to a xib, and link outlets to cotrols and control actions to object’s method, but once I press the button everything just crashes (uknown selector).

Do you guys have a hint around that?

EDIT: The code, as requested:

@interface TextController {
    IBOutlet UILabel * textLabel;
    IBOutlet UITextField * textField;
}

-(IBAction)buttonClicked:(id)sender;

@end

@implementation TextController

-(IBAction)buttonClicked:(id)sender {
    textLabel.text = @"Ololo";
}

@end

Connections in IB are ok, just believe me. It’s really hard to get them wrong with all this drag’n’drop stuff 🙂

EDIT 2: TextController is not a file owner (in this case it works fine). However, I just want to understand why I can’t wire up an action to some object (may be even not a subclass of UIViewController).

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:36:37+00:00Added an answer on May 12, 2026 at 3:36 pm

    You can wire outlets and actions to any object in the nib-file. Drag an NSObject form the library palette onto your nib-file, in Interface Builder. Then go to the Identity tab of the information palette and set the Class of your object.

    This way you can instantiate any object of any class from your nib. If the target you want to hook to is statically created from the nib-file. Make sure that the file’s owner have at least one reference to your object, or else it will be deallocated as soon as it has been created. Targets are not retained by the sender.

    If the object you want to hook up should not be statically created from your nib, then implement awakeFromNib in a class that is instantiated from the nib-file and hook up the targets in code.

    Last option is if you do not have any sub-class of your own in the nib-file at all. Then implement initWithNibName:bundle: in your UIViewController subclass, and hook up your targets in code after calling the super implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The question may sound a bit stupid but I think it's interesting. Is it
This question may seem a bit stupid, but i'm new to Joomla! And i
The question may sound a bit naive or stupid, but i was wondering...will POST
This may be a stupid question but I can't seem to figure this out.
The question may be a bit theoretical (did I mean rhetorical?) or fuzzy, but
This may bit a bit of a basic question, but I can't seem to
This may be a bit of a weird question, but is there any reliable
My question may sound a little bit stupid. My team has to test a
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
This may be a bit of daft question, but I don't come from an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.