views:

60

answers:

1

I want to make a button in an UIAlertView that opens a Wikipedia page, with a subject stored in my array "array"

Here is how I'm doing it.

Wikipedia follows the format of http://en.wikipedia.org/wiki/<subject>. In my array, I have text entries of subjects. I want it to open in mobile Safari when tapped. So far, no luck :(

Help please. Any insight would be appreciated.

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {

NSString *myString = [[NSString alloc] init];

myString = [array objectAtIndex:myInteger];

NSURL *theURL = [NSURL URLWithString:@"http://en.wikipedia.org/wiki/"];
NSString *halfURL = [NSString stringWithFormat:@"%@", theURL];
NSString *fullURL = [halfURL stringByAppendingString:myString];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullURL ]];

}

A: 

oh, turns out that i needed to replace the gaps in the strings in the arrays with % to work as a proper link, so it would open.,

Sam Jarman