I am trying to download a file from a server to an iphone like this
NSURL *newURL0 = [NSURL URLWithString: url];
NSMutableURLRequest *req0 = [NSMutableURLRequest requestWithURL:newURL0];
NSURLConnection conn = [[NSURLConnection alloc] initWithRequest:req0 delegate:self];
and then
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSURL *docDirectory = [[[NSFileManager defaultManager] URLsForDirectory:
NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSURL *filePath = [docDirectory URLByAppendingPathComponent:temp];
[webData writeToURL:filePath atomically:YES];
[webData release];
connection = nil ;
if ([delegate respondsToSelector:@selector(getDataSucceeded:)]) {
NSLog(@"Log: %@", @"yes");
[delegate getDataSucceeded:self.list];
}
}
This always worked perfectly, but recently I have noticed that it does not work anymore. No changes were made to any files relevant to this function, it just kind of stopped working. when I use the same url in a web browser the file downloads fine, but in my app when I request the file it just returns 5 bytes, the word ‘False’ which I also found strange because the server does not return the word False, if there is an issue it returns a error message. The server side code is written in Visual Basic.
Any thoughts or suggestions are much appreciated
Falseis a keyword in Visual Basic, it is not a keyword in Objective-C. There’s also no reason for that to appear as text in a response like that. It’s almost certainly being generated server-side.Use an HTTP proxy such as Charles to see what requests are made by your web browser and by your application. There will be a difference between them that is causing the server to respond in a different way. Use a tool like cURL to make requests manually to determine which of the differences is the cause. Alternatively, check the commit log for your server-side code for recent changes that could cause this.