gpt4 book ai didi

iphone - 如何在Objective C中为iPhone应用程序设置值?

转载 作者:行者123 更新时间:2023-12-02 23:24:45 26 4
gpt4 key购买 nike

我是Objective C的新手,正在为iPhone进行开发,因此,如果这是一个简单的答案,我深表歉意。我已经尝试搜索Google进行了3天的搜索,并购买了iPhone Development for Dummies,但没有运气。

本质上,我想做的就是在按下按钮时播放声音,然后在音频文件的值上加1。所以举个例子

//Play audio file (y.wav)   ---y being the variable I would like to set.
if (y > 13) { ---there are a total of 14 sounds starting with file 0.wav going to 13.wav.
y = 0; ---so if the value is greater than 13 I want to start the cycle over with y equaling 0.
} else {
y++; ---if y is not greater than 13 I want to add one to it so it plays the next sound file next time.
}

我确实有一段关于JavaScript的历史,因此该示例比JavaScript更加体现了JavaScript。该应用程序类似于iFart,但是在开始我的论点之前,我不打算制作另一个实际上不是我制作的放屁/打ping应用程序,这只是我的应用程序这一部分的相似概念。因此,如果有人可以帮助我学习如何将其转换为Objective-C或实现目标的完全不同的方法,我将不胜感激。

谢谢乔伊

最佳答案

- (void) playMySound
{
static int soundIndex = 0;
const int soundCount = 14;

// create sound name from base string and wound index, as Jeff shows above

// play the sound

if (++soundIndex >= soundCount)
{
soundIndex = 0;
}

// or just do it in one line, viz
//soundIndex = (soundIndex + 1) % soundCount;

}

关于iphone - 如何在Objective C中为iPhone应用程序设置值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1204373/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com