English 中文(简体)
如果是NSArray和NSMutable 总是使用射线而不是正常的阵列?
原标题:Should NSArray and NSMutableArray be always used instead of normal C arrays?

I have a piece of code in C# and I am rewriting it in Objective C. The code uses arrays a lot like double[]and also array of Point structure. so shall i simply used C style array to store Objective C double and CGPoint for my task OR is it a good practice to use NSArrays or NSMutableArrays every time along with NSValue or NSNumber to store non-objects in them.

我可以很好地使用一个平原阵列,但这种阵列又是根据大小在运行时间产生的,因此,我是否应该使用小面积,并且可以自由地完成同样的任务?

NOTE:

This the C# code, I am trying to implement in Objective C, if anyone has a converted code, please help me out. I tried but, doesn t seem to work for me.

最佳回答

您正在从C#中转换,用以下两种语文转换:un Boxedprimitive打字的类型和结构,例如double,以及 Boxed阵列。 类型,例如,相当于NSNumber的物体,载于Obj-C。

C# range of un Boxed doubles (same hold for other primitive categories and structure) are someway between Obj-C double[ ] and an NSArrays - in C# elements are un Boxed (as in double[]),而阵列本身则是管理对象(如:ArNSray。

C#盒式阵列等于 NSArrays of NSObjects.

你如何选择?

  • 如果“C”编号有固定型号(Obj-)C阵列。

  • 如果C#代码是不同的盒式阵列,则使用Obj-CNSArray

  • 如果您对C++表示高兴,可计量的无箱型阵列将考虑vector

  • 除此以外,对每个元素的箱子成本(10 000)NSNumbers,与doubles 和阵列的记忆管理( Smalloc/>>.free vs. />>>>>>>release vs. ARC/GC. 一般来说,但并非绝对规则,没有箱式的种类的阵列最好作为C阵列,而箱式类型阵列最优于<代码>。 NSArrays。

问题回答

虽然通常更能使用NS物体,但如果你收集非物体,则在使用小型/免费或将非目标数据整理成可储存物体之间产生权衡效应。 只能储存NSO物体。 两倍之多,你可以把NSNumber用作集装箱。 对于CG Point和其他构件,你可以制造新的物体类型,或强迫进入NSData物体。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签