我使用nsxmlparser来解析来自服务器的数据。我正在尝试将数据传递给详细信息表视图,但我无法将数据传入NSString。
这是我的.xml
<?xml version="1.0" encoding="UTF-8"?>
< videos >
<Video id="1">
<name>Video 1</name>
<link>http://www.ebookfrenzy.com/ios_book/movie/movie.mov</link>
</Video>
<Video id="2">
<name>Video 2</name>
<link>http://www.ebookfrenzy.com/ios_book/movie/movie.mov</link>
</Video>
<Video id="3">
<name>Video 3</name>
<link>http://www.ebookfrenzy.com/ios_book/movie/movie.mov</link>
</Video>
<Video id="4">
<name>Video 4</name>
<link>http://www.ebookfrenzy.com/ios_book/movie/movie.mov</link>
</Video>
<Video id="5">
<name>Video 5</name>
<link>http://www.ebookfrenzy.com/ios_book/movie/movie.mov</link>
</Video>
<Video id="6">
<name>Video 6</name>
<link>http://www.ebookfrenzy.com/ios_book/movie/movie.mov</link>
</Video>
</videos >
链接是相同的,没关系。问题是我无法将此链接输入NSString。以下是我尝试的方法:
NSString *videoString = [[videos objectAtIndex:indexPath.row] objectForKey:@"link"];
NSURL *fileURL = [NSURL URLWithString:videoString];
mp = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[mp.view setFrame:CGRectMake(0, 70, 320, 270)];
[self.view addSubview:mp.view];
mp.fullscreen = YES;
[mp play];
如果我尝试在UILabel中使用元素,我可以在标签中显示它。
UILabel *label;
label.text = [[videos objectAtIndex:indexPath.row] objectForKey:@"name"];
然而,当我尝试将其作为NSString检索时,我是不成功的。
如何将元素用作NSString? Thanx提前..