class.m 中的数组以及如何在其中添加值 Objective-c
Array in class.m and how to add values in it Objective-c
我想在 class 中添加一个数组并给它一些值并在主 class 中调用它。我正在使用
@property(nonatomic) NSArray *subject;
但我无法从实现中访问它 class。我想访问它并在其中添加一些随机值。
#import "yourClass.h"
@implementation yourClass
@synthesize subject;
- (void)viewDidLoad
{
[super viewDidLoad];
subject=[[NSArray alloc]initWithObjects:@"one",@"two",@"three", nil];
}
在您的 class.m 下方 @implementation
合成你的数组
您可以使用 _subject
从实现 class 访问它
或
Synthesize your property in your `.m file`
喜欢:
@implementation MyClass
@synthesize subject;
我想在 class 中添加一个数组并给它一些值并在主 class 中调用它。我正在使用
@property(nonatomic) NSArray *subject;
但我无法从实现中访问它 class。我想访问它并在其中添加一些随机值。
#import "yourClass.h"
@implementation yourClass
@synthesize subject;
- (void)viewDidLoad
{
[super viewDidLoad];
subject=[[NSArray alloc]initWithObjects:@"one",@"two",@"three", nil];
}
在您的 class.m 下方 @implementation 合成你的数组
您可以使用 _subject
或
Synthesize your property in your `.m file`
喜欢:
@implementation MyClass
@synthesize subject;