Make an NSString accessible in the whole class

Posted by OhhMee on Stack Overflow See other posts from Stack Overflow or by OhhMee
Published on 2011-01-06T03:05:48Z Indexed on 2011/01/06 3:53 UTC
Read the original article Hit count: 164

Filed under:
|
|

Hello,

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;    
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa-touch