Hi guys,
I'm new at iphone sdk, and experimenting some problems with variables.
What I'm trying to do is load an Array from a plist file, and show a random String in a WebView. And when a button is pressed it gets other random string from the array.
In the simulator, when the program loads it shows a string, but when I press the button, the program shuts down.
Here's the plist:
When view loads
I'm getting "Local declarations of 'getText' hides instance variable" on the red text
When the button is pressed:
Thanks in advance!
Regards
Ruben Oliveira
I'm new at iphone sdk, and experimenting some problems with variables.
What I'm trying to do is load an Array from a plist file, and show a random String in a WebView. And when a button is pressed it gets other random string from the array.
In the simulator, when the program loads it shows a string, but when I press the button, the program shuts down.
Here's the plist:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>ssssssssssssss</string>
<string>llllllllllllllllllllllllll</string>
<string>okokokok</string>
<string>ljdcosijc</string>
<string>kwhcoiwkjscb</string>
<string>ksjjjjjjjjjjjj</string>
</array>
</plist>
When view loads
I'm getting "Local declarations of 'getText' hides instance variable" on the red text
Code:
- (void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"Quotes.plist"];
NSMutableArray *allText = [[NSMutableArray alloc] initWithContentsOfFile:finalPath];
NSString *getText = [[NSString alloc] init];
[COLOR="Red"]getText = [allText objectAtIndex:(arc4random() % [allText count])];
email = [[NSString alloc] initWithString:getText]; [/COLOR]
texto.backgroundColor = [UIColor clearColor];
[COLOR="Red"][texto loadHTMLString:getText baseURL:nil];
}[/COLOR]
When the button is pressed:
Code:
-(IBAction)mostraTexto{
[getText release];
getText = [allText objectAtIndex:(arc4random() % [allText count])];
[email release];
email= [NSString stringWithString: getText];
[texto loadHTMLString:getText baseURL:nil];
}
Thanks in advance!
Regards
Ruben Oliveira