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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:07:05+00:00 2026-06-11T23:07:05+00:00

I have the following: Class 1: .h file: @interface class1 : UIViewController @property (assign,nonatomic)

  • 0

I have the following:

Class 1:

.h file:
@interface class1 : UIViewController

@property (assign,nonatomic) int number;

.m file:

- (void)viewDidLoad
{
    [super viewDidLoad];
number=1;
}

Class2:

.h file:
@interface class2 : UIView{
    class1 *Controller;
}

@property (retain,nonatomic) class1 *controller;

but if access the number variable from anywhere in the second class the value is 0 any of you knows why?

  • 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-11T23:07:06+00:00Added an answer on June 11, 2026 at 11:07 pm

    Is the class already open and retained somewhere (i.e. your navigation stack)? If so you can then safely access and modify variables because they are already initialized. If not that’s probably why you’re getting 0 returned.

    Another way is to create and maintain a data singleton that all view controllers can draw data from easily and you can then reference that data singleton to modify and change values.

    Assuming the view controller is already initialized and active you can then do something like this:

    MyViewController *vc = [[MyViewController alloc] init];
    [vc setValue:@"100"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following UIViewController class: FILE: ResultsDataViewController.h @interface ResultsDataViewController : UIViewController @property (nonatomic,
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following two class: //file FruitTree.h @interface FruitTree : NSObject { Fruit
I have a ViewController class with the following structure: Header file: @protocol GCStageViewControllerDelegate; @interface
I have the following class interface: class Time { public: Time( int = 0,
I have the following Class: ---- .h file #import <Foundation/Foundation.h> #import MapperProtocoll.h @interface ServiceRequest
I have the following class in a php file: function calcTotal(){ var productID =
I have the following classes in my models file class HardwareNode(models.Model): ip_address = models.CharField(max_length=15)
I currently have a class file with the following enumeration: using System; namespace Helper

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.