Redeclare在iOS应用程序中的BOOL类型的2d数组 [英] Redeclare 2d array of BOOL type in iOS app

查看:120
本文介绍了Redeclare在iOS应用程序中的BOOL类型的2d数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发iOS应用程序,我在.h文件中的公共接口中创建了2d数组的BOOL,像这样

I am developing iOS application, I have created 2d array of BOOL in my public interface in .h file like this


BOOL数组[10] [10];

BOOL array[10][10];

现在在.m文件在某些​​功能我想redecalre它与一些其他大小可能

Now in .m file in some function i want to redecalre it with some other size may be


array [20] [20]

array[20][20]

推荐答案

如果你使用C数组,它们是不可变的,一旦你分配一个固定大小的数组你不能改变它。

if you use C array they are immutable, once you alloc an array of a fixed size you cannot change it.

我已经在使用订阅的二维数组的可能性实现上发布了一个解决方案:

I have posted a solution here on a possibile implementation for 2d arrays using subscription:

2d阵列实例变量的Objective-c语法< a>

Objective-c syntax for 2d array instance variable

如果你使用C数组,你必须自己管理内存,所以你可以在.h中声明一个指向2d数组的指针, free,realloc和copy如果需要更大的数组。我不建议这种方法。

if you use C array you have to manage the memory yourself, so you can declare a pointer to a 2d array in the .h and alloc memory using new, free, realloc and copy if a bigger array is necessary. i dont suggest this approach.

这篇关于Redeclare在iOS应用程序中的BOOL类型的2d数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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