iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication

Yes. Stop using the synchronous API. If you use the asynchronous delegate-based API then you have a lot more control over the connection. With this API, except in cases where an error is encountered before the HTTP header is received, you will always receive -connection:didReceiveResponse:, which gives you access to the HTTP header fields (encapsulated … Read more

Problem using NSURLRequest to POST data to server

You should remove the leading & in myRequestString and the problem is likely that the correct content-type header is not being sent. Try adding a call to [request setValue:@”application/x-www-form-urlencoded” forHTTPHeaderField:@”content-type”]; You should also not pass nil for error, so you can see what the client thinks is going on. Unrelated, but your PHP code is … Read more

iPhone: NSHTTPCookie is not saved across app restarts

You can save the cookie by saving its properties dictionary and then restoring as a new cookiebefore you go to re-connect. Save: NSArray* allCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:URL]]; for (NSHTTPCookie *cookie in allCookies) { if ([cookie.name isEqualToString:MY_COOKIE]) { NSMutableDictionary* cookieDictionary = [NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:PREF_KEY]]; [cookieDictionary setValue:cookie.properties forKey:URL]; [[NSUserDefaults standardUserDefaults] setObject:cookieDictionary forKey:PREF_KEY]; } } … Read more

Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

There is a possibility to add images (to be exact: icons or symbols) to the buttons of a UIActionSheet (or a UIAlertView) without loading image files or fiddling around with (sub)views. In these classes buttons are specified by their titles, which are strings. So it is obvious to use symbols, which one can specify also … Read more

Is it possible for a UIWebView to save and autofill previously entered form values (e.g., username & password)?

From my looking I don’t think there is an easy way to do it. Here is an idea of what might work though: create your uiwebview create a nsurlrequest after your webview delegate page loaded function fires look in the request’s http body find the form for login (regex for common login forms?) retrieve give … Read more

Does UIWebView send the same User-Agent in the Request Headers as mobile Safari?

Web requests made from UIWebView will not include the word “Safari” in the User Agent string. Web requests made from Mobile Safari will. This is the best way I have found for determining of a request is coming from within an app or from Mobile Safari. Sample User Agent from UIWebView within App: User-Agent: Mozilla/5.0 … Read more