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

  • Home
  • SEARCH
  • 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 604723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:04:09+00:00 2026-05-13T17:04:09+00:00

Just beginning with iPhone development i seem to miss something fundamental. In a View

  • 0

Just beginning with iPhone development i seem to miss something fundamental.

In a View based application i’m adding programaticaly a UIView subclass in the ViewController implementation file and can set a value:

- (void)viewDidLoad {

    [super viewDidLoad];

 CGRect myRect = CGRectMake(20, 50, 250, 320);

 GraphView *graphView = [[GraphView alloc] initWithFrame:myRect];

 [self.view addSubview:graphView];

    graphView.myString = @"Working here";

}

When i try to change the same value with an action in the same file, the Build fails because graphView is undeclared:

- (void)puschButton1 {


 graphView.myString = @"Not working here";

}

Because I use a UIView subclass there is no outlet for my GraphView instance.

How can i get a reference to my subview? Or should this be done in another way?

Thanks in advance

Frank

  • 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-13T17:04:10+00:00Added an answer on May 13, 2026 at 5:04 pm

    The easiest solution is to make graphView an instance variable for your view controller, instead of declaring it in viewDidLoad.

    Put something like this in your .h file:

    @class GraphView;
    
    @interface MyViewController : UIViewController {
        GraphView *graphView;
    }
    
    // ... method declarations ...
    
    @end
    

    If you don’t want to do that, another way is to set graphView‘s tag property, and then call the superview’s viewWithTag: method to retrieve the view when you need it.

    I’m not sure what you mean by “Because I use a UIView subclass there is no outlet for my GraphView instance.” You generally declare outlets on your controller class, and it doesn’t matter whether you are using a subclass of UIView.

    As an aside, I’ll note that you should probably release that GraphView at some point, or you’ll have a memory leak.

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

Sidebar

Related Questions

I'm just beginning iPhone development, so please bear with me. I'm looking to make
I'm just beginning to have a look at Objective-C and Cocoa with a view
I am just beginning to write an application. Part of what it needs to
I've been reading three books (iPhone Game Development, iPhone cookbook and beginning iPhone development),
I was following the example on Beginning iPhone 3 Development. On Chapter 8 I
I am just beginning to do research into the feasibility of using Amazon's SimpleDB
I'm just beginning work with IIS, .NET, etc. so I apologize if any of
I am just beginning the move to the .NET Framework 3.5. I use CruiseControl.NET
I'm just beginning to use Regex so bear with my terminology. I have a
I'm beginning to fall in love with Extension Methods, but I just don't know

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.