How Make the players waiting [closed] - ios

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I wonder How Make the players waiting؟ like candy crush When the player loses all points of Health He must wait some time
How i can do this?
Thanks

Create a date object when the player loses
NSDate *stopTime = [NSDate dateWithTimeIntervalSinceNow:0];
and store that date in NSUserDefaults. To check if the user has waited long enough, read the date from NSUserDefaults, and compute the delta between the stop time and the current time. For example, if the user needs to wait 15 minutes, then
NSTimeInterval delta = [stopTime timeIntervalSinceNow];
delta = -delta;
if ( delta > 15 * 60 )
// OK to play
else
// still waiting

Related

is there a way to measure Swift's performance without building UI on iPhone with Xcode 11? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to measure performance of different swift libraries without writing UI on iPhone. There are many examples of Swift/UI examples that are normally, multi-threaded in nature. So what I want to measure is raw performance without gui overhead, if possible. And the output can we printed into the Xcode 11 console window in debugger, for example. Could you please kindly point me where I could find such sample code ? I would greatly appreciate the help.
This is an example of how to measure the time of a sum of numbers
let numbersArray = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6]
func showBenchmarkTime(title:String, operation:()->()) {
let startTime = CFAbsoluteTimeGetCurrent()
operation()
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
print("Time elapsed for \(title): \(timeElapsed) s.")
}
showBenchmarkTime(title: "sum an array of numbers") {
print(numbersArray.reduce(0, +))
}

if rebinding doesn’t mutate the existing memory location of a variable, how do i get the old value after a rebind. forexample: [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
cat_poop = 12
> 12
if i rebind cat_poop to a new value forexample:
cat_poop = 20
> 20
So how do i get the first value of cat_poop after a rebind
You cannot get the previous value after an Elixir variable is rebound.

Random generator based off NStimer Xcode 7 swift 2 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want a function to be called at random times while the user is playing. For example after 2 seconds passed a function is called and then after another 6 seconds it is called again. How do I do that?
This is not working
func time() {
randomNumber = CGFloat((drand48())
timer = NSTimer.scheduledTimerWithTimeInterval(randomNumber, traget: self, selector: "startTimer", userInfo: nil, repeats: true)
Xcode is not liking it and I donot know why
Welcome to SO. This is not a site where you get other people to write your code for you. It's a site to ask for help with code you write yourself.
You want to use arc4random_uniform() to create a random number, and then scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: to fire your timer at a random time in the future.
Try that, and if you have problems, update your question with the code you're trying and tell us what happens with it.
Edit:
Here's a suggestion: log a few values of randomNumber. Are they small values? Those are a delay in seconds. If you are getting values of 1000, 1,000,000, or greater, it's going to take a while for your timer to fire.

Counter System for iOS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
how can i make a counter to be used in addressing issues. (sample output: Issue 001). I need to save the current value of the counter(001) in the device so that when there is another issue to be sent by the app i will increment the current value of the counter.
Don't know where to start.
thanks in advance.
You can use the NSUserDefaults
get and store the value
NSInteger count = [[[NSUserDefaults standardUserDefaults] valueForKey:#"count"] integerValue];
count++;
[[NSUserDefaults standardUserDefaults]setValue:[NSNumber numberWithInteger:count] forKey:#"count"];

AudioPlayer fast Forward in Xcode [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Is there a way to fast forward an audio file by x2, x4 etc by the use of a button? If not, do you have any idea how this would be possible?
NSTimeInterval *timeIntervel = [yourPlayer currentTime];
timeIntervel = timeIntervel + timeToForword;
[yourPlayer setCurrentTime:timeIntervel];
[yourPlayer play];

Resources