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 8531353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:27:52+00:00 2026-06-11T09:27:52+00:00

I have created an outlet for a textview and I’m trying to use it

  • 0

I have created an outlet for a textview and I’m trying to use it in a function, outside of the function it works fine, inside its not declared. When I pass it along with the function like StartFunction(textBox) it works fine, but this function also has to work with a bunch of other things like this and I don’t like the idea of just passing everything with the function.

What would be a better alternative?

// Header File
- (IBAction)startButton_clicked:(id)sender;
@property (strong, nonatomic) IBOutlet UITextView *textBox;

// Main file
- (IBAction)startButton_clicked:(id)sender {
    if (currentlyOn == false) StartFunction(headLabel);
        else textBox.text = @"Already Started"; // Works fine here
            }

void StartFunction(UILabel *_headLabel)
{
    _headLabel.text = @"This works fine because it's passed with the function";
    textBox.text = @"textBox is undeclared here";
}
  • 1 1 Answer
  • 0 Views
  • 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-06-11T09:27:53+00:00Added an answer on June 11, 2026 at 9:27 am

    It sounds like you need to use a method rather than a function for your situation.

    A method is really a type of function which is silently passed a reference to an instance of itself, this is given the name self. Using that reference the method can access instance variables, methods and properties. Uses of self are also often silently added for you.

    So, assuming your code is part of myClass your method startButton_clicked is approximately (we’re glossing over a few details) the same as the function:

    IBAction startButton_clicked(myClass *self, id sender)
    {
        if (currentlyRecording == false)
           StartRecordingAudio(headLabel);
        else
           self.textBox.text = @"Already Started"; // Works fine here
    }
    

    Note the extra argument and the use of self in the assignment. The method call:

    [someInstanceOfMyClass startButton_clicked:theSender];
    

    is approximately equivalent to:

    startButton_clicked(someInstanceOfMyClass, theSender);
    

    which is where the silently passed self comes from.

    Functions are not treated in this way at all, there is no hidden argument passed, and lacking that silent way to access instance variables, properties and methods.

    Both methods and functions have their uses and you select based on the need. In your case it sounds like you need a method as you wish to access an instance.

    HTH.

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

Sidebar

Related Questions

I have created a function that shows/hides different messages according to a combination of
I have created an outlet collection for several buttons , now I need change
I have created a controller class in which I have created a outlet to
I have an NSComboBox in my mainmenunib file. I have created an outlet of
I have a UIImageView object created in IB, and has an outlet. I want
I have created a custom UIView that I would like to use on multiple
I have created the outlet and property. Now can One please help me how
i want to use custom fonts in y application. i have declared the Fonts
I have created a QWidget with a bunch of QToolButtons in it and I
I have created 3 classes as following Ext.mine.TextParent - Inherting from Textfield Ext.mine.child.TextChildA -

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.