Cocoa touch 加载维基百科页面

Cocoa touch 加载维基百科页面,cocoa-touch,nsurl,Cocoa Touch,Nsurl,我想在UIAlertView中创建一个按钮,打开一个Wikipedia页面,主题存储在我的数组“array”中 这就是我的做法 维基百科采用http://en.wikipedia.org/wiki/。在我的数组中,我有主题的文本条目。我想在移动Safari中点击时打开它。到目前为止,没有运气:( 请帮忙。如有任何见解,将不胜感激 -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonInde

我想在
UIAlertView
中创建一个按钮,打开一个Wikipedia页面,主题存储在我的数组“array”中

这就是我的做法

维基百科采用
http://en.wikipedia.org/wiki/
。在我的数组中,我有主题的文本条目。我想在移动Safari中点击时打开它。到目前为止,没有运气:(

请帮忙。如有任何见解,将不胜感激

-(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 ]];

}

哦,原来我需要用%替换数组中字符串中的间隙,以用作正确的链接,这样它就可以打开了