English 中文(简体)
目标-C 检查在指挥线路应用中是否存在URL
原标题:Objective-C checking if URL exists in Command Line application

我有一个简单的指挥线应用程序,测试档案的存在。 然而,这些档案非常庞大,我要核实,它们没有下载整个档案。 这是我掌握的,但下载了每个档案:

            NSURL *url = [NSURL URLWithString:downloadPath];
            NSURLRequest *request = [NSURLRequest requestWithURL:url];
            NSURLResponse *response = nil;
            NSError **error=nil; 
            NSData *data=[[NSData alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:error]];

            NSInteger httpStatus = [((NSHTTPURLResponse *)response) statusCode];

            if(httpStatus == 404)
            {
                NSLog(@"%@ NOT FOUND!",[productDic objectForKey:@"fileName"]);

            }

The files I am looking for are .zip and are not found locally.

最佳回答

如果你提出“欧洲复兴开发银行”要求,而不是“GET”要求,你可能会在以下几段之后得到:

NSMutableURLRequest *request = [[NSURLRequest requestWithURL:url] mutableCopy];
[request setHTTPMethod:@"HEAD"];
[request autorelease];
问题回答

暂无回答




相关问题
Command Line Parameters

I m trying to add my file in Visual Studio as command line parameters. I know my code works since when I use fopen("whole path here", "r"), it runs. I then add the file as a command line parameter ...

Read from File, or STDIN

I ve written a command line utility that uses getopt for parsing arguments given on the command line. I would also like to have a filename be an optional argument, such as it is in other utilities ...

R - capturing elements of R output into text files

I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...

热门标签