iphone - converting NSString to precise number for performSelector: afterDelay: -


I am communicating with a webservice to get the numeric value in my function as an NSString This number tells me the exact time to wait until taking another action, and it is important that this is accurate.

As an example, if the string is "89283", that means that I should wait 89.283 seconds. So I would like to know the best way in Objective-C so that the iPhone can convert this string to an exact value that I can pass to display: later: function. Here's my sample code, but I'm making an accurate estimate of it.

  NSString * myDelayString = @ "89283"; Int myDelay = [myDelayString intValue] / 1000; [Selector to self: Object with @centor (myfunction): after zero: my dell];  

I think my della value should actually be an NSTimeInterval, but I'm not sure how to make a string with me thank you in advanced.

There is a code with the change to allow double precision.

  NSString * myDelayString = @ "89283"; NSTimeInterval myDelay = [myDelayString doubleValue] / 1000; [Selector to self: Object with @centor (myfunction): after zero: my dell];  

Use double values ​​to get the string as double so that you can avoid integer division. The type of NSTimeInterval is defined as double on the iPhone, so you can add double results in it and then you can give it later: Part of the selector.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -