模拟器、iPhone 上 NSDictionary 的返回值
我有一些代码需要 iPhone 才能运行。不过,我确实想在模拟器上测试我的应用程序。在 iPhone 上,我用它来返回一个值:
return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:-1], @"number"];
我正在寻找类似的东西我想:
- (NSDictionary *) data
{
#if TARGET_IPHONE_SIMULATOR
something in here to return a value of 70;
#else .....
我想返回一个值 70 以在模拟器中使用。
有人可以帮我吗?
I have some code which requires an iPhone to run. I do however want to test my app on the simulator. On the iPhone I use this to return a value:
return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:-1], @"number"];
I'm looking for something like this I THINK:
- (NSDictionary *) data
{
#if TARGET_IPHONE_SIMULATOR
something in here to return a value of 70;
#else .....
I want to return a value of 70 for use in the simulator.
Could somebody help me out here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
始终以
nil
终止您的+dictionaryWithObjectsAndKeys:
,否则您会随机崩溃。如果只有 1 个键,最好使用+dictionaryWithObject:forKey:
。使用
#else
。或者,更干净地说,
Always terminate your
+dictionaryWithObjectsAndKeys:
withnil
otherwise you'll get random crash. If there's only 1 key, it's better to use+dictionaryWithObject:forKey:
.Use
#else
.Or, more cleanly,