获取数据:(空)在MSmutabledata的转换到ios中的string

嗨即时通讯试图在我的表中通过获取数据库中的url播放韦迪斯,我已经使用了JSON和PHP代码,通过在即时通讯中的URL得到一些问题。

我试图将nsmutable数据转换为NString传递moiveplayer的url,但我得到的数据空转换没有发生。

这是我必须用来连接到JSON对象的url的代码:

-(void)setDataSource:(vedios *)inVideosObj { self.titile.text = inVideosObj.title; url =[NSURL URLWithString:inVideosObj.video]; NSURLRequest *request =[NSURLRequest requestWithURL:url]; connection =[[NSURLConnection alloc] initWithRequest:request delegate:self]; self.responseData = [[NSMutableData alloc]init]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; { [self.responseData appendData:data]; } 

我已经尝试了很多代码,但没有任何工作我在控制台中得到相同的数据空错误

这是我用于转换的代码:

  - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // NSAssert(self.responseData, @"Response data should not be nil"); NSString *urlString = [[NSString alloc]initWithData:self.responseData encoding:NSUTF8StringEncoding]; // NSString *urlString = [[[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding]autoContentAccessingProxy]; NSAssert(self.responseData, @"This should not be nil for a valid response"); NSLog(@"data :%@",urlString); MPMoviePlayerController *mov = [[MPMoviePlayerController alloc]initWithContentURL: [NSURL URLWithString:urlString]]; // MPMoviePlayerController *mov = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL URLWithString:urlString]]; // MPMoviePlayerController *mov = [[MPMoviePlayerController alloc]initWithContentURL:url]; self.movieplayer = mov; [self.movieplayer.view setFrame:CGRectMake(10,20, 100, 100)]; self.movieplayer.movieSourceType = MPMovieSourceTypeFile; [self.contentView addSubview:self.movieplayer.view]; [self.movieplayer prepareToPlay]; [self.movieplayer play]; } 

在控制台即时获取像这样

 2014-01-24 09:55:27.987 video[537:a0b] data :(null) 

我认为url不传递给电影播放器​​,但如果我给直接url的工作,如果我使用转换的NSMutable数据string转换不会发生。

请按照以下链接: –

 https://github.com/jdriscoll/JCDHTTPConnection https://github.com/rickerbh/NSURLConnection-Blocks 

你可以尝试使用Block版本。