我正在尝试使用BEncoding ObjC类来解码.torrent文件.
NSData *rawdata = [NSData dataWithContentsOfFile:@"/path/to/the.torrent"];
NSData *torrent = [BEncoding objectFromEncodedData:rawdata];
Run Code Online (Sandbox Code Playgroud)
当我NSLog torrent得到以下内容时:
{
announce = <68747470 3a2f2f74 6f727265 6e742e75 62756e74 752e636f 6d3a3639 36392f61 6e6e6f75 6e6365>;
comment = <5562756e 74752043 44207265 6c656173 65732e75 62756e74 752e636f 6d>;
"creation date" = 1225365524;
info = {
length = 732766208;
name = <7562756e 74752d38 2e31302d 6465736b 746f702d 69333836 2e69736f>;
"piece length" = 524288;
....
Run Code Online (Sandbox Code Playgroud)
如何将其name转换为NSString?我试过了..
NSData *info = [torrent valueForKey:@"info"];
NSData *name = [info valueForKey:@"name"]; …Run Code Online (Sandbox Code Playgroud) - (IBAction)startDownloadingURL:(id)sender
{
// create the request
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/index.html"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLDownload *theDownload=[[NSURLDownload alloc] initWithRequest:theRequest delegate:self];
if (!theDownload) {
// inform the user that the download could not be made
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行模拟器时,我收到一个错误:
NSURLDownload unclared,首次使用此功能.
我在哪里可以导入NSURLDownload库.