nsurlsession

NSURLSession returns data as Null on Watch OS2 using Objective-C

自作多情 提交于 2019-12-20 01:56:06
问题 This works perfectly on iPhone (Simlulator and Device) but on Watch OS2 i get blank data. What might be the issue with this ? NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithRequest:theRequest completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) { theData = [[NSString alloc]initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding]; NSLog(@"%@", theData); }]; [task resume]; 回答1: Sorry found the

NSURLSessionDataTask acting suspiciously slow

北慕城南 提交于 2019-12-20 01:41:52
问题 I'm getting JSON data from the web, parse it, then using it to diplay pins on a map. Here is method one, which there is no problem with: NSString *CLIENT_ID = @"SECRET_ID"; NSString *CLIENT_SECRET = @"CLIENT_SECRET"; NSString *SEARCH = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?near=gjovik&query=cafe&client_id=%@&client_secret=%@&v=20140119", CLIENT_ID, CLIENT_SECRET]; NSURL *searchResults = [NSURL URLWithString:SEARCH]; NSData *jsonData = [NSData

WebService API Method in Swift 3 and Swift 4?

穿精又带淫゛_ 提交于 2019-12-19 11:36:53
问题 I am new to Swift iOS and i want to create a separate method in separate class(like NSObject ) of web services so that i can use it in any ViewController and parse any type of JSON response using NSURLSession and Alamofire . Could someone help me. 回答1: class WebRequester: NSObject { static let shared = WebRequester() let session = URLSession.shared func request(urlStr:String, parameter:String, token:String? = nil, callback:@escaping (_ result:NSDictionary?, error:Error?) -> Void) { let url =

How return data from an HTTP request in Swift/Objective C

岁酱吖の 提交于 2019-12-19 10:21:17
问题 I'm trying to use Coinbase's API to get information about my online bitcoin wallet, and I'm trying to use Swift's NSURLSession object to do so. Perhaps I'm missing something obvious in the Apple docs, but after reading through the information about NSURLSession and NSURLSessionTask I still do not understand how to make an HTTP request and then return the body of the response so that the body can persist throughout the life of my app. As of now I only see the ability to use completion blocks

Getting server data for the Apple Watch

亡梦爱人 提交于 2019-12-19 07:41:28
问题 I am wondering how to go about designing a watchOS app that depends on getting the latest feed from a server. Would you need to use application context and just have the iPhone push it over in the background using the WatchConnectivity framework or would you use NSURLSession on the Apple Watch itself? Keep in mind this is for watchOS 2. 回答1: You can use NSURLSession to handle your request. So your request would be native on your watchn. But note that your watch is there to show simple Content

ios FTP upload using NSURLSession

僤鯓⒐⒋嵵緔 提交于 2019-12-19 05:18:23
问题 I am trying to upload files via FTP to server. According to Apple Documentation NSURLSession class supports FTP operations. There is a famous Apple Developer blog which also supports that. But still its not clear whether NSURLSession API's supports ftp upload or not? (I tried with the way suggested and getting error). With the conventional way of CFFTPStreamRef, ftp upload works fine but it's deprecated in 9.0. The header says: CF_DEPRECATED(10_3, 10_11, 2_0, 9_0 , "Use NSURLSessionAPI for

ios FTP upload using NSURLSession

℡╲_俬逩灬. 提交于 2019-12-19 05:18:06
问题 I am trying to upload files via FTP to server. According to Apple Documentation NSURLSession class supports FTP operations. There is a famous Apple Developer blog which also supports that. But still its not clear whether NSURLSession API's supports ftp upload or not? (I tried with the way suggested and getting error). With the conventional way of CFFTPStreamRef, ftp upload works fine but it's deprecated in 9.0. The header says: CF_DEPRECATED(10_3, 10_11, 2_0, 9_0 , "Use NSURLSessionAPI for

NSURLSessionDataTask not executing the completion handler block

不羁岁月 提交于 2019-12-18 23:14:50
问题 I am trying to pull some data from my local node server. The server is getting the get request and logging it, but for some reason my iOS app will not execute any of the code that I have in the completion handler. Here is the code: - (IBAction) buttonPressed{ NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:3000/"]; NSURLSessionDataTask *dataTask = [self.session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error){ nameLabel.text = @"yay!"; /* if

NSUrlSessionDownloadTask - didCompleteWithError when go in background

Deadly 提交于 2019-12-18 16:49:39
问题 When I force my device to go in sleep mode by pressing the power button, my background task stops by calling the delegate method didCompleteWithError with the error : The operation couldn’t be completed. Operation not permitted How can I configure my NSURLSession to continue the download even in sleep mode? Is it even possible? If not, what options do I have? I need to download a file of 300Mb, so with a low connection the application will go in sleep mode before the end of the download. Here

IOS9 SSL error with NSURLSession

℡╲_俬逩灬. 提交于 2019-12-18 15:49:41
问题 I have developed an IOS App that is communicating with a Server using HTTPs (I'm also the developer of the server, it's embedding a Tomcat server). This App is working without any issues with IOS8 but it's not with IOS9. I get the following error when sending an HTTPs request: Session download has failed : Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x7fa9c44b2e40 {NSErrorFailingURLStringKey=https://127.0