nsurlsession

Initializer does not override a designated initializer while subclassing NSURLSession Swift

别来无恙 提交于 2019-12-11 13:15:42
问题 I want to subclass NSURLSession class, but I have problem with initialisation. Basically I override the constructor and initialising the constant authUrl there then calling the parent init method. class NSURLAuthSession: NSURLSession { let authUrl:NSURL; //Error: Initializer does not override a designated initializer from its superclass override init(configuration: NSURLSessionConfiguration, delegate: NSURLSessionDelegate?, delegateQueue queue: NSOperationQueue?){ self.authUrl = NSURL

Return value in NSURLSession Error

ぃ、小莉子 提交于 2019-12-11 13:13:32
问题 I get below error while trying to return responseString Incompatible block pointer types sending 'NSString *(^)(NSData *__strong, NSURLResponse *__strong, NSError *__strong)' to parameter of type 'void (^)(NSData *__strong, NSURLResponse *__strong, NSError *__strong)' where i call it from Suppose AViewController Class NSString *responseString=[self callAPI]; And below is my code in BViewModel class: -(NSString* )callAPI { NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration

What is the best practice to call URL in apple watch?

∥☆過路亽.° 提交于 2019-12-11 12:59:00
问题 What is the best practice to call API from Apple watch use sendMessage "watchConnectivity" from Apple watch to iPhone to call the API or use NSURLSession to call the API from the watch itself ? 回答1: Using the NSURLSession API, the device that performs the request is abstracted from the developer. If the phone is available, it will perform the request on the phone and return it to your watch app as if the watch itself performed the request. If the phone is not available, the watch can perform

HTTPMaximumConnectionsPerHost is ignored in AFHTTPSessionManager

拥有回忆 提交于 2019-12-11 12:42:39
问题 I am trying to use AFNetworking2.0 with new NSURLSession class to fetch some data. In particular I am interested in new HTTPMaximumConnectionsPerHost property of NSURLSessionConfiguration but unfortunately it doesn't seem to work as I expect. @interface ViewController () @property (nonatomic, strong) AFHTTPSessionManager *httpSessionManager; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSURLSessionConfiguration *sessionConfig = [[NSURLSessionConfiguration

Upload image to server through POST method ios

廉价感情. 提交于 2019-12-11 12:22:51
问题 I want to upload image to server through post method. The format should be like ["ImageName"=Image] . I have tried the following code but it doesn't upload the image to server. Can anyone help me ? -(void)SaveImageToServer:(UIImage*)getImage :(NSString*)imageName :(NSString*)getUrlToSaveImg withCompletionBlock:(void(^)(NSMutableArray *))completionBlock { NSMutableArray *arrrrr=[[NSMutableArray alloc]init]; NSMutableURLRequest *reqqq=[[NSMutableURLRequest alloc]initWithURL: [NSURL

No data receiving with NSURLSession

China☆狼群 提交于 2019-12-11 11:40:44
问题 My post request works fine (I have a good response and no error) but I have no data receiving too.. Normally when I am on my browser on this site https://conventiondestage.insa-toulouse.fr/index.php I complete the form and after login I can see the content of the page accueil.php but why my function does not return data (I want the html content of this page) ? Thanks for your help ! This is the log in console : 2014-04-07 17:52:00.207 myINSA[22797:60b] Response:<NSHTTPURLResponse: 0x14e92d50>

Warning about sendsynchronousRequest:returningResponse:error: is deprecated:first seprecated in ios 9-

旧街凉风 提交于 2019-12-11 10:34:07
问题 And it says use [NSURLSession sharedsession] dataTaskwithRequest:request completionHandler:] So here my code: NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; I changed above code to like this: NSData *returnData = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:nil]; I got 2 warning: Null passed to a callee that requirs a non-null argument Incomplete pointer type initializing 'NSData' with a expression of type

NSURLSession + HTTPS is any other setup needed?

瘦欲@ 提交于 2019-12-11 09:53:49
问题 I'm sending with POST some data to server using NSURLSession , I did it over HTTP, now I had to change to HTTPS. To my pleasant surprise all is working fine, which means that all I did was changing url from http to https. But is it enough? Should I take any additional steps? Is it secured? The server has SSL certificate. 来源: https://stackoverflow.com/questions/25864622/nsurlsession-https-is-any-other-setup-needed

Locating file descriptor leak in OS X application

旧城冷巷雨未停 提交于 2019-12-11 06:06:48
问题 Background I have some very complex application. It is composition of couple libraries. Now QA team found the some problem (something reports an error). Fromm logs I can see that application is leaking a file descriptors (+1000 after 7 hours of automated tests). QA team has delivered rapport "opened files and ports" from "Activity monitor" and I know exactly to which server connection is not closed. From full application logs I can see that leak is quite systematic (there is no sudden burst),

How to clear cached data stored by URLSession/URLConfiguration?

我是研究僧i 提交于 2019-12-11 05:13:55
问题 I am using the code below to set the caching policy of my URLSession via URLConfiguration. if appDelegateObj.configuration == nil { appDelegateObj.configuration = URLSessionConfiguration.default } if self.apiType == ServerRequest.API_TYPES_NAME.API1 { if appDelegateObj.forceReload == true { appDelegateObj.configuration?.urlCache = nil appDelegateObj.configuration?.requestCachePolicy = .reloadIgnoringLocalCacheData }else{ appDelegateObj.configuration?.requestCachePolicy =