Wednesday 15 July 2015

ios - Send multiple NSURLSession -


I have a NSURLSession that looks like this, and what I want to, if No data is returned, then I say do it to try again to go 8 seconds or three attempts and then if there is still anything, so I do not return any data it. What I have now here,

  NSURL session * session = [NSURL session shared session]; [[Session dataTaskWithURL: [NSURL URLWithString: urlIn] completionHandler: ^ (NSData * data, NSURLResponse * reaction, NSError * Error) {// handle response // use my data // if no data I do not try again Want to }] BioData];  

So I want to try to pass it 3 times or 8 seconds. How can I go about doing it myself,

Thanks in advance for your help

< P> OK, I'm almost there, I need a bit more to work with the timer. Here's what I have.

I get the attribute

  try NSInteger; NSIEtegaord _counter; NSDT * date = [NSDT date];  

And then these two methods for my timer

  - (zero) start countdown {_counter = 8; NSTimer * Timer = [NSTimer Scheduled Timer with Time Interval: 1 Goal: Self Selector: @Selector (Outlined Timer :) User Information: Zero Repeats: Yes]; } - (zero) Countdown timer: (NSTimer *) timer {_counter--; If (_counter & lt; = 0) {[Invalid timer]; NSLog (@ "8 seconds pass"); }}  

and after that I am getting my data.

  - (zero) getMenuItems: (NSString *) urlIn {NSURL session = session = [NSURL session sharing session]; [[Session dataTaskWithURL: [NSURL URLWithString: urlIn] completionHandler: ^ (NSData * data, NSURLResponse * response, NSError * error) I am facing a problem if I have to call the timer for main thread ([ date timeIntervalSinceNow] & Lt; = 8 & amp; amp; amp; amp; amp; amp; [feedback required] Contact Lambi] == 0] {tryInt ++; [self Milnuims: URL];} if (Try & gt; = 3) {Anselog (@ "no data");} else if ((required contact Lang) == 0) try {Anselog (@ "again"); attemptInt ++; [self Milnuim S: URL];} Else {// Get my stats} myself.Iamadata = [[Meladata Elok] Init: data];}  

So I tried to set a timer I just need to know with just a few seconds that 8 seconds have passed before or not?


No comments:

Post a Comment