ios __NSArrayI 和 __NSArrayM 是什么?如何转换为 NSArray?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7684611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is __NSArrayI and __NSArrayM? How to convert to NSArray?
提问by ChangUZ
What is __NSArrayI and __NSArrayM?
__NSArrayI 和 __NSArrayM 是什么?
__NSArrayI(or M) cause "unrecognized selector" error.
__NSArrayI(或 M)导致“无法识别的选择器”错误。
How to convert to NSArray?
如何转换为 NSArray?
I did test to parse json, twitter api.
我做了测试来解析 json,twitter api。
http://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name=twitterapi
http://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name=twitterapi
==> works fine. parsed object is NSCFDictionary class. (This dictionary contains __NSArrayM class)
==> 工作正常。解析的对象是 NSCFDictionary 类。(本字典包含 __NSArrayM 类)
http://api.twitter.com/1/statuses/user_timeline.json?&screen_name=twitterapi
http://api.twitter.com/1/statuses/user_timeline.json?&screen_name=twitterapi
==> error. parsed object is __NSArrayM class.
==> 错误。解析的对象是 __NSArrayM 类。
回答by Jason
__NSArrayI
is a code-word for an immutable array - that is, a "regular" NSArray
which you cannot change.
__NSArrayI
是不可变数组的代码字 - 即,NSArray
您无法更改的“常规” 。
__NSArrayM
is a code-word for a mutable array - that is, NSMutableArray
. In NSMutableArray
, you can add and remove items.
__NSArrayM
是可变数组的代码字 - 即NSMutableArray
. 在 中NSMutableArray
,您可以添加和删除项目。
回答by Alex Cio
These are classes of the private api. There is a projectwhere you can see all classes of the private api. You are not allowed to use them inside an app for the app store
but sometimes it is useful too see how to access the objects and also what kind of object it is. They cannot be converted. I think, getting these kind of objects inside the debugger is just the representation of internal classes, for the classes you are using inside your project. Knowing what kind of class it is, lets you also understand where to look for the problem inside your code.
这些是私有 api 的类。有一个项目,您可以在其中看到私有 api 的所有类。您不允许在应用程序中使用它们,app store
但有时查看如何访问对象以及它是什么类型的对象也很有用。它们无法转换。我认为,在调试器中获取这些类型的对象只是内部类的表示,对于您在项目中使用的类。了解它是什么类型的类,还可以让您了解在代码中查找问题的位置。
Here you can see a short lookup of both:
在这里您可以看到两者的简短查找:
__NSArrayI
__NSArrayI
__NSArrayM
__NSArrayM
回答by Nekto
It is private classes. You shouldn't want to access them or moreover convert them.
是私人班级。您不应该想要访问它们或转换它们。
If I'm not mistaken NSArray
is subclass of _NSArray
.
如果我没记错的话NSArray
是_NSArray
.
If you are adding/removing some objects to/from your array check that it is of mutable type : NSMutableArray
如果您在数组中添加/删除一些对象,请检查它是否为可变类型: NSMutableArray