Iphone NSURL连接将/赢得';t加载数据
这就是我的问题: 我几乎完全遵循了iPhone开发者文档中的说明,它只是有点起作用 这里是所有问题的症结所在:Iphone NSURL连接将/赢得';t加载数据,iphone,objective-c,iphone-sdk-3.0,ios-simulator,nsurlconnection,Iphone,Objective C,Iphone Sdk 3.0,Ios Simulator,Nsurlconnection,这就是我的问题: 我几乎完全遵循了iPhone开发者文档中的说明,它只是有点起作用 这里是所有问题的症结所在: 该对象似乎创建正确,并委托ConnectionIDFinishLoading,但对于我尝试加载的任何URL,响应数据总是以0字节结束。如果有什么不同,我会在模拟器中运行 这是我的相关代码: - (void)viewDidLoad { [super viewDidLoad]; self.title = @"WVFS Player"; //create a req
该对象似乎创建正确,并委托ConnectionIDFinishLoading,但对于我尝试加载的任何URL,响应数据总是以0字节结束。如果有什么不同,我会在模拟器中运行 这是我的相关代码:
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"WVFS Player";
//create a request
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://wvfs.josh-kaplan.com/nowPlaying.php"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create a connection
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection) {
// create the datum
responseData=[[NSMutableData data] retain];
} else {
// code this later
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[responseData setLength:0];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// make it work
NSLog(@"Succeeded! Received %d bytes of data:",[responseData length]);
// release it
[connection release];
[responseData release];
}
下面是我的日志输出:
[Session started at 2010-03-14 09:01:09 -0400.]
2010-03-14 09:01:14.784 WVFS[19571:207] Succeeded! Received 0 bytes of data:
有什么想法吗 您忘记实现
连接:didReceiveData:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
您忘记实现
连接:didReceiveData:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}