等价的C ++ STL容器“对< T1,T2>在Objective-C? [英] Equivalent of C++ STL container "pair<T1, T2>" in Objective-C?

查看:130
本文介绍了等价的C ++ STL容器“对< T1,T2>在Objective-C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Objective-C的新手,所以请不要对我太多。我想知道:是否有一个等价的C ++ STL对容器我可以在Objective-C中使用?



我想构建一个数组包含一个NSInteger关联到NSBool。我知道我可以使用一个数组,每个条目是一个NSDictionary与一个键值,但我发现它是一个有点过分。



任何想法? >

感谢。

解决方案

您可以在Objective-C ++中使用STL。所有你需要做的是将.m文件的扩展名更改为.mm,我还建议您使用 #import 而不是 #include 。这样你可以使用你的对STL容器。


I'm new to Objective-C, so please don't judge me too much. I was wondering: Is there an equivalent of the C++ STL pair container I can use in Objective-C?

I want to build an array that contains an NSInteger associated to an NSBool. I know I could use an array with each entry being a NSDictionary with a single key-value but I find it to be a little overkill.

Any ideas?

Thanks.

解决方案

You can use the STL in Objective-C++. All you need to do is change the extension of your .m file to .mm and I would also advise you use #import instead of #include. That way you can use your pair STL container.

这篇关于等价的C ++ STL容器“对< T1,T2>在Objective-C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆