nsurlsession

Unexpected Non-Void Return Value In Void Function (Swift 2.0)

若如初见. 提交于 2019-11-26 07:36:30
问题 I have been skimming the StackOverflow questions trying to figure out where I\'m going wrong with my code, but I just can\'t seem to! I am trying to convert my Swift 1.2 project to Swift 2.0, and am having an issue with my class that downloads JSON data. I am continually receiving the error Unexpected non-void return value in void function . Here is the code, somewhat truncated, that I am using; ... class func fetchMinionData() -> [Minion] { var myURL = \"http://myurl/test.json\" let dataURL

How to send POST and GET request?

雨燕双飞 提交于 2019-11-26 06:55:11
问题 I want to send my JSON to a URL ( POST and GET ). NSMutableDictionary *JSONDict = [[NSMutableDictionary alloc] init]; [JSONDict setValue:\"myValue\" forKey:\"myKey\"]; NSData *JSONData = [NSJSONSerialization dataWithJSONObject:self options:kNilOptions error:nil]; My current request code isn\'t working. NSMutableURLRequest *requestData = [[NSMutableURLRequest alloc] init]; [requestData setURL:[NSURL URLWithString:@\"http://fake.url/\"];]; [requestData setHTTPMethod:@\"POST\"]; [requestData

NSURLSession/NSURLConnection HTTP load failed on iOS 9

不打扰是莪最后的温柔 提交于 2019-11-26 03:13:48
问题 Tried to run my existing app on iOS9 but getting failure while using AFURLSessionManager . __block NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { if (error) { } else { } }]; [task resume]; I get the following error: Error Domain=NSURLErrorDomain Code=-999 \"cancelled. Also getting following logs: NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL,

Send POST request using NSURLSession

二次信任 提交于 2019-11-26 03:00:09
问题 Update: Solution found. You can read it at the end of the post. I\'m trying to perform a POST request to a remote REST API using NSURLSession . The idea is to make a request with two parameters: deviceId and textContent . The problem is that those parameters are not recognized by the server. The server part works correctly because I\'ve sent a POST using POSTMAN for Google Chrome and it worked perfectly. This is the code I\'m using right now: NSString *deviceID = [[NSUserDefaults

How to use special character in NSURL?

帅比萌擦擦* 提交于 2019-11-26 02:38:34
问题 My application is using an NSURL like this: var url = NSURL(string: \"http://www.geonames.org/search.html?q=Aïn+Béïda+Algeria&country=\") When I tried to make a task for getting data from this NSURL like this: let task = NSURLSession.sharedSession().dataTaskWithURL(url!, completionHandler: { (data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in if error == nil { var urlContent = NSString(data: data, encoding: NSUTF8StringEncoding) println(\"urlContent \\(urlContent!)\") } else

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

点点圈 提交于 2019-11-26 00:18:44
问题 I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0. Somehow it started giving me the Titled error \"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection\" Webservice Method: -(void)ServiceCall:(NSString*)ServiceName :(NSString *)DataString { NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration]; [sessionConfiguration setAllowsCellularAccess:YES];

How can I get the Data from NSURLSession.sharedSession().dataTaskWithRequest

十年热恋 提交于 2019-11-25 22:00:16
问题 class PostFOrData { let url = NSURL( string: \"http://210.61.209.194:8088/SmarttvWebServiceTopmsoApi/GetReadlist\") var picUrl = NSURL(string : \"http://210.61.209.194:8088/SmarttvMedia/img/epi00001.png\") var responseString : NSString = \"\" func forData() -> NSString { let request = NSMutableURLRequest( URL: url!) request.HTTPMethod = \"POST\" var s : NSString = \"\" let postString : String = \"uid=59\" request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding) let task =