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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:39+00:00 2026-05-28T06:10:39+00:00

i have 2 classes in my app. View1 & View2; i want to use

  • 0

i have 2 classes in my app. View1 & View2;
i want to use an object like array, strin, label.text in another class
when i used them the shows null ;

View1.h:
{
NSMutableArray *array;
IBOutlet UILabel *lbl;
NSString *str;
}

@property(nonatomic,retain) NSMutableArray *array;
@property(nonatomic,retain)IBOutlet UILabel *lbl;
@property(nonatomic,retain) NSString *str;

@end;

View1.m

@synthesize array;
@synthesize lbl;
@synthesize str;


array = (1,2,3,..., nil) some dataa
str = @"HAI";
lbl.text = @"Text in label aaaa";

NSLog( @" %@", array );
NSLog( @" %@", lbl.text );
NSLog( @" %@", str );

gives correct out put

but in
View2:

@implementation View2
    #import "View1"
    .
..
....
View1 *one = [View1 alloc]initwit.....................];

NSLog( @" %@", one.array );
NSLog( @" %@", one.lbl.text );
NSLog( @" %@", one.str );

prints null value

why ? what to do?

thanks in advance..

  • 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-28T06:10:40+00:00Added an answer on May 28, 2026 at 6:10 am

    Very easy. You can allocate this array in your AppDelegate, and then call it from your UIViews. Or you can allocate it in one of your UIViews and set point to this array into AppDelegate.
    Example:

    //UIView 1 
    NSArray *array = [[NSArray alloc] init];
    MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    appDelegate.mySharedArray = array;
    
    //UIView2
     MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
     NSArray *array = appDelegate.mySharedArray;
    

    Thats it

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

Sidebar

Related Questions

I have custom classes that I currently instantiate within App.xaml as resources. I want
I have some classes in my app that don't require an ID to be
I'm creating an iPad app, and I have two classes: NWRootViewController : UITableViewController and
I'm making a shopping cart app in Google App Engine. I have many classes
I'm building an app around Vici Coolstorage (asp.net version). I have my classes created
I have classes which have automatic properties only like public customerName {get; set;}. They
I have two classes in my app class A and Class B. Both class
I have a collection that contains instances of several different classes, and I want
In my app I have the classes User, Video, and Vote. Users and Videos
I have one activity, off this I have two classes. When my app starts

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.