0
我正在使用可变数组。我不确定这是否是管理阵列的正确方法。我试图学习内存管理的基础知识,但我发现它很难掌握。我做的是管理阵列的正确方法
声明数组在界面
@interface myVC()
@property (nonatomic,strong) NSMutableArray *substrings; // if I use weak attribute here,does it change anything?
@end
-(void)myMethod{
// initializing the array
_substrings=[[NSMutableArray alloc]init];
//storing some data into it
[_substrings addObject:@"hello"];
//do something with the data in that array
//call another method which gets the data from this same array and do some operations there
[self method2];-----> // I access data from the array like, x=[_substrings objectatindex:0];
//finally, remove the items in the array
[_substrings removeObject:@"hello"];
//and again start the process as mentioned here
}
这是我在想什么做的。这是声明和访问和管理数组的正确方法吗?