ObjectiveC,创建类数组
我有一个包含值的类:
@interface Params : NSObject {
[...]
NSString *fc;
NSString *sp;
NSString *x;
NSString *y;
[...]
@property (nonatomic, assign) NSString *fc;
@property (nonatomic, assign) NSString *sp;
@property (nonatomic, assign) NSString *x;
@property (nonatomic, assign) NSString *y;
[...]
@end
可以在 Objective-c 中创建一个类数组吗?像c#/java?
MyClass[] a = new MyClass[20] ???
a[0].fc = "asd" ?
或同等的东西?
谢谢, 阿尔贝托
I have a class that contains values:
@interface Params : NSObject {
[...]
NSString *fc;
NSString *sp;
NSString *x;
NSString *y;
[...]
@property (nonatomic, assign) NSString *fc;
@property (nonatomic, assign) NSString *sp;
@property (nonatomic, assign) NSString *x;
@property (nonatomic, assign) NSString *y;
[...]
@end
it's possible to create in objective-c an array of classes? like c# / java?
MyClass[] a = new MyClass[20] ???
a[0].fc = "asd" ?
or something equivalent?
thanks,
alberto
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然执行此操作的标准方法是使用
NSArray
,但您也可以使用 C 样式数组来执行此操作:但是,使用
NSArray
会简单得多。 :)While the standard way to do this would be with an
NSArray
, you can do this with a C-style array as well:However, using an
NSArray
would be much simpler. :)您可以使用标准的 NSArray 来执行此操作,在我的示例中我使用了视图,但您可以使用指向任何对象的指针。
You would use a standard
NSArray
to do this, in my example I have used views, but you can use pointers to any object.