English 中文(简体)
阵列中的浮点阵列结构: 避免 NNSValue 的紧凑方式?
原标题:ObjC structs of floats in arrays: Compact way to avoid NSValue?

我将一些联署材料移植到本地的 ObjC 代码中。 因为支架不能在阵列内安装, 需要包装它 。

联署材料守则如下:

var bezierVertices = [{0: 14},{10: 32},{24: 16}];

JS:对匿名物品进行拼写。

我受以下要求的约束: 代码是否尽可能紧凑,意思是说,在使用[NSValue value value withCGPoint:ccp(x,y)]提出NSValue 的NSValue 国家空间空间系统时,我被拒绝了。

他们想要像上述联署材料那样紧凑。

Before writing something as ugly as an NSString like @"0:14;10:32;24:16"; that s split and parsed in a loop, I thought SO could help bring something clean :) I m allowed to use .mm so ObjC++ solutions could fit as well, but I m not knowledgeable about C++ at all...

Thanks! J.

最佳回答

他们想要像上述联署材料所述那样的契约

他们知道"目标C"是编译的语言吗?

总之,大吵大闹,你可以做C阵列 CGPoints像这样:

CGPoint myArray[] = {{0.0, 14.0}, {10.0, 32.0}, {24.0, 16.0}}; 

这是标准 CA 源代码源。 您得到这样的元素数 :

int nElements = sizeof myArray / sizeof(CGPoint);
问题回答

如果您需要管理可变长的脊椎阵列, C++ 提供 std:: victor< CGPoint>





相关问题
Nested struct variable initialization

How can I initialize this nested struct in C? typedef struct _s0 { int size; double * elems; }StructInner ; typedef struct _s1 { StructInner a, b, c, d, e; long f; char[16] s; }...

passing primitive or struct type as function argument

I m trying to write some reasonably generic networking code. I have several kinds of packets, each represented by a different struct. The function where all my sending occurs looks like: - (void)...

Error: "Cannot modify the return value" c#

I m using auto-implemented properties. I guess the fastest way to fix following is to declare my own backing variable? public Point Origin { get; set; } Origin.X = 10; // fails with CS1612 Error ...

Sending struct over TCP (C-programming)

I have a client and server program where I want to send an entire struct from the client and then output the struct member "ID" on the server. I have done all the connecting etc and already managed ...

Scheme, getting the pointer from pointed struct

Assume I have a such struct: (define-struct node (value next)) ;and making 2 nodes, parent pointing to child as next. (define child (make-node 2 null)) (define parent (make-node 1 child)) Under ...

Changing a struct inside another struct in a foreach loop

The following code prints (when invoking MyMethod): 0 0 0 1 I would expect it to print: 0 0 1 1 Why is this? Code: private struct MyStruct { public MyInnerStruct innerStruct; } private ...

热门标签