Make an NSString accessible in the whole class
- by OhhMee
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;
}