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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:56:14+00:00 2026-05-18T23:56:14+00:00

I want to know how can I make an NSString accessible in the whole

  • 0

I want to know how can I make an NSString accessible in the whole class. Say I have these codes:

    - (void) init { 
        NSArray *elements  = [xpathParser search:@"//foo"];
            TFHppleElement *element = [elements objectAtIndex:0];
            NSString *data  = [element content];

        NSArray *elements1  = [xpathParser search:@"//foo2"];
            TFHppleElement *element2 = [elements1 objectAtIndex:0];
            NSString *data2 = [element2 content];
    }

And I want to use data & data2 in the whole class, how can I do that?

I want to show results here:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell.


    switch (indexPath.row) {

        case 0 :

            cell.textLabel.text = (@"%@", data);

            break;

        case 1: 

            cell.textLabel.text = (@"%@", data2);

            break;
}
    // Email & Password Section


    return cell;    
}
  • 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-18T23:56:14+00:00Added an answer on May 18, 2026 at 11:56 pm

    Make them variables inside the class by declaring them outside of the method, like:

    NSString *data;
    NSString *data2;
    
    - (void) init { 
      NSArray *elements  = [xpathParser search:@"//foo"];
      TFHppleElement *element = [elements objectAtIndex:0];
      data = [[element content] retain];
    
      NSArray *elements1  = [xpathParser search:@"//foo2"];
      TFHppleElement *element2 = [elements1 objectAtIndex:0];
      data2 = [[element2 content] retain];
    }
    

    and later:

    - (void)dealloc {
      [data release];
      [data2 release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to know how i can make my code Plugin/Priendliy. Lets say :
I just want to know that can i make an application which have some
I want to know how I can make a Java program where an unknown
I want to know how I can make a validator for a key which
sorry i am a new comer,i just want to know how we can make
I have a custom UIView class, and in the - (void)drawRect:(CGRect)rect I want to
I want to know how can I make the string I converted from DWORD
I want to know what language can make my template being dynamic. Example HTML
I want to know that can we make paypel related application in j2me and
I want to know how I can make website available in my private home

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.