nsurlrequest

NSData and Uploading Images via POST in iOS

妖精的绣舞 提交于 2019-12-17 04:14:22
问题 I have been combing through the many many posts about uploading images via POST in iOS. Despite the wealth of information on this topic, I cannot manage to correctly upload JPEG data taken from my iPhone Simulator Photo Library. The data, once on the server, is just a huge string of hexidecimal. Shouldn't NSData just be a byte stream? I don't get whats going on with all the hex, or why this code seems to work for everyone else. Here is the code in question: -(void)uploadWithUserLocationString

Swift GET request with parameters

僤鯓⒐⒋嵵緔 提交于 2019-12-17 02:59:19
问题 I'm very new to swift, so I will probably have a lot of faults in my code but what I'm trying to achieve is send a GET request to a localhost server with paramters. More so I'm trying to achieve it given my function take two parameters baseURL:string,params:NSDictionary . I am not sure how to combine those two into the actual URLRequest ? Here is what I have tried so far func sendRequest(url:String,params:NSDictionary){ let urls: NSURL! = NSURL(string:url) var request = NSMutableURLRequest

NSURLConnection with POST doesn't work

梦想与她 提交于 2019-12-14 03:29:43
问题 I'm trying request a URL parsing parameters with POST, but mypage.php is not receiving this parameters... Here is my code: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://myurl/mypage.php"]]; NSString *params = [[NSString alloc]initWithFormat:@"name=%@&surname=%@&location=%@&email=%@&password=%@&gender=%@&tipo=%@", name, surname, location, email, password, gender, tipo]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[params

Grails Multipart Service Stream ended unexpectedly

若如初见. 提交于 2019-12-13 19:17:01
问题 I'm coding an ios app and I need to send photo from my app to my grails server. In ios i do this: +(void)sendPhoto:(NSData *)data withName:(NSString *)name onController:(UIViewController<MERequestDelegate> *)controller { MERequest *request = [[MERequest alloc] init]; request.delegate = controller; //User User *user = [User loadUser]; //Creazione del BOdy della richiesta Multipart NSMutableData *body = [[NSMutableData alloc] init]; //Token [body appendData:[[NSString stringWithFormat:@"\r\n--%

Xcode, ensure codes after blocks run later for NSURLConnection asynchronous request

岁酱吖の 提交于 2019-12-13 18:33:01
问题 Hi there: I have been writing an iOS program which uses many http queries to the backend rails server, and hence there are tons of codes like below. In this case, it is updating a UITableView : //making requests before this... NSOperationQueue* queue = [[NSOperationQueue alloc] init]; [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse* response, NSData* data, NSError* error) { NSLog(@"Request sent!"); NSHTTPURLResponse* httpResponse =

iPhone SDK: How to check if IP entered by user is valid?

こ雲淡風輕ζ 提交于 2019-12-13 14:25:56
问题 My iPhone application includes several http requests to a server. The server's IP address can be entered by the user so you can use the app in combination with your own private server. Before making the requests I always check whether or not the IP address entered is valid and I do it like this: -(BOOL)urlExists { NSString *url = [NSString stringWithFormat:@"%@", ipAddress]; NSURLRequest *myRequest1 = [NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy

iOS remove special characters from URL string [closed]

扶醉桌前 提交于 2019-12-13 09:40:34
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I want to call this URL using NSURLRequest: http://www.test.com/query={"tag1":"üğişi","tag2":"çöçödd"} These characters which are "üğişi" and "çöçödd" UTF8 character. I need to convert this URL to get response.

How to pass authorization token header objective c?

≯℡__Kan透↙ 提交于 2019-12-13 08:46:58
问题 I'm passing username,password for an API call it returns right value. But after authentication API returns an security token I need to capture the token and pass along with username and password.I'm doing the same but it returns forbidden error which denotes invalid token error.I also tried base64 to pass token as suggested at some answer in stackoverflow.The code I use to pass header values below NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:

Google Places API web service using swift returns error 303

南笙酒味 提交于 2019-12-13 05:42:59
问题 I am trying to use the Google Places Web Service through iOS (using swift). The reason I want to do so - I want to allow browsing places on a map, even if they are not nearby (the only search allowed using the iOS provided library). I also need to do it programmatically (since in one use-case I want to allow browsing the map, while in another use case - I want the places to be constant and not change based on the map camera). I can't use the iOS place picker, since I want the map to display

iOS: How to load local files (not in the bundle) in a WKWebView?

喜欢而已 提交于 2019-12-13 05:29:06
问题 I would like to use a WKWebView (not a UIWebView) and load some html files in it. I precise that I put the ArbitraryLoads to YES in info.plist. (For info, it works on simulator but not on device). <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> Here is my code: WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init]; [theConfiguration setMediaPlaybackAllowsAirPlay:YES]; [theConfiguration setAllowsInlineMediaPlayback:YES];