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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:26:30+00:00 2026-05-28T02:26:30+00:00

I have my ViewController.h/m and another class Keyboard.h/m. In my ViewController.h I have an

  • 0

I have my ViewController.h/m and another class Keyboard.h/m.
In my ViewController.h I have an UILabel:

@interface ViewController : UIViewController{

UILabel *label;

}

@property (nonatomic, retain) IBOutlet UILabel *label;

and my ViewController.m looks so

#import "ViewController.h"
@synthesize label;
...

Now I want to change the label from Keyboard.m.
I have tried something like this:

#import "ViewController.h"
...
ViewController *vc;
vc.label.text = @"text";

it compiles without any errors but the label doesn’t change

  • 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-05-28T02:26:31+00:00Added an answer on May 28, 2026 at 2:26 am

    It’s very error prone that you’re doing here.

    ViewController *vc;
    

    declares a pointer, but this won’t be initialized; so when you’re accessing its property vc.label.text, objc_messageSend() will be passed a bogus pointer, so it can potentially crash! (you’re lucky if id didn’t do so.)

    Anyways: if you have done it well, like ViewController *vc = [[ViewController alloc] init]; creating a new instance wouldn’t have affected the other instance. You have to store the pointer to your instance somewhere, e. g. set a @property (retain) ViewContrller *vc; to your application’s app delegate object, and access it through that property like this:

    [(MyAppDelegate *)[[UIApplication sharedApplication] delegate] vc].label.text = @"new text";
    

    that way it should work.

    Hope it helps.

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

Sidebar

Related Questions

I have UINavigationController and UIViewController, then I push another viewcontroller, but I don't need
I'm developing an iOS 4 application. I have a ViewController that contains another class.
I have the following code in my AppDelegate : #import <UIKit/UIKit.h> @class PersonalDiarySystemViewController; @interface
Let's say I have an abstract class called ViewController, and another abstract class called
I have a UIViewController Class Aplha that calls another UIViewController Class Beta in a
I have a strange problem with integrating a ViewController into another ViewController . i
I have created two viewController classes such that one is superclass of another.i have
I have added a navigation controller inside a viewcontroller thats inside another navigation controller...
I need to have a new view(w/ ViewController) added over the top of another.
I have a ViewController class called GamePlay. In GamePlay there is a nested class

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.