其他类中的 NSMutable Array [英] NSMutable Array in other class

查看:33
本文介绍了其他类中的 NSMutable Array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 .h 中声明了一个 NSMutableArray 并设置了属性和合成,但是如果我想在其他类中使用这个数组?我怎么办?

I declared an NSMutableArray in my .h and I set property and synthesize, but if i want use this array in other class? How I do?

推荐答案

如果你如你所说,为 NSMutableArray 创建了一个 @property,你可以很容易地按名称在其他类中访问它.例如:

If you have, as you stated, created an @property for the NSMutableArray, you can easily access it in other classes by name. For example:

#import "MyClass.h"

...

MyClass *myClass = [[MyClass alloc]init];
NSMutableArray *array = [myClass.myArray mutableCopy];

(注意:我没有使用内存管理.)

(Note: I did not use memory management.)

这篇关于其他类中的 NSMutable Array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆