如何创建随机选择的 NSString“包”适用于 iPhone 应用程序
我正在研究 Objective C 和 Cocoa Touch,并且正在尝试构建一个供个人使用的应用程序。
我的目标是创建一个应用程序,在 iPhone 屏幕的中央窗口中显示随机 NSString,同时在屏幕一侧的另一个窗口中显示关联 NSString 的可滚动列表。
例如:如果中心 NSString 是动物的名称,例如“狮子”,则旁边列表中的 NSString 也将是动物(例如“老虎”、“雪豹”等)
我想创建关联 NSString 的“包”,让程序随机选择一个“包”,在中心随机显示其中一个 NSString,并在给定时间后在可滚动侧窗口中同时显示包中其他 NSString 的列表。间隔然后程序将循环并选择另一个 NSString,排除之前显示的“包”中的内容。
创建它们是否可行?
我的主要兴趣是如何创建 NSString 的此类“包”,因为我刚刚开始 我希望有人能为我的研究指明正确的方向,以便我知道应该使用哪些工具来开始实验,
我非常感谢任何建议或示例代码
。
I'm just delving into Objective C and Cocoa Touch and I'm trying to build an app for personal use.
My goal is to create an app that displays a randomized NSString in a center window on the iPhone screen while also displaying a scrollable list of associated NSStrings in another window on the side of the screen.
For example: if the center NSString is the name of an animal, such as "Lion", the NSStrings on the list next to it would also be animals (e.g., "Tiger", Snow Leopard", etc.)
I would like to create "packages" of associated NSStrings, have the program randomly select a "package", randomly display one of its NSStrings in the center, and simultaneously display a list of the other NSStrings in the package in the scrollable side window. After a given time interval the program would then loop and select another NSString, excluding those in the previously displayed "package".
My main interest is how to create such "packages" of NSStrings. Is it feasible to use NSDictionary or NSArray to create them?
Since I am just starting out I am hoping that someone can point me in the right direction in my research so that I know what tools I should use to begin experimenting.
I'd very much appreciate any recommendations or example code.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同时使用 NSArray 和 NSDictionary。
例如:
您可以使用
[NSDictionary allKeys]
获取所有密钥Use both NSArray and NSDictionary for it.
For example:
And you can get all keys using
[NSDictionary allKeys]