Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 无法在NSMutableArray中存储UIImage_Objective C_Cocoa Touch_Uiimage_Nsmutablearray - Fatal编程技术网

Objective c 无法在NSMutableArray中存储UIImage

Objective c 无法在NSMutableArray中存储UIImage,objective-c,cocoa-touch,uiimage,nsmutablearray,Objective C,Cocoa Touch,Uiimage,Nsmutablearray,我试图将UIImage存储在NSMutableArray中,但它不起作用,下面是我使用的行: [images addObject:QRImage]; 没有编译错误,但是当我调试应用程序时,我看到NSMutableArray有0个对象。i、 e.未添加映像。我怀疑您的NSMutableArray未正确初始化。试试这个: NSMutableArray *images = [[NSMutableArray alloc] init]; // ... [images addObject:QRImage]

我试图将
UIImage
存储在
NSMutableArray
中,但它不起作用,下面是我使用的行:

[images addObject:QRImage];

没有编译错误,但是当我调试应用程序时,我看到
NSMutableArray
有0个对象。i、 e.未添加映像。

我怀疑您的
NSMutableArray
未正确初始化。试试这个:

NSMutableArray *images = [[NSMutableArray alloc] init];
// ...
[images addObject:QRImage];

提供更多代码。谢谢。您的
NSMutableArray
是否已分配?什么不起作用?您正在尝试添加QRImage类吗?至少你会遭受可怕的实例名的折磨。@Flex_上瘾的nsarray和Co不是语言的一部分,而是cocoa(-touch)框架。请留下标签。这里没有足够的信息。为了形成一个有根据的猜测,我们需要知道a)运行此代码的上下文,以及b)如何以及在什么上下文中测量数组的长度;在视图didLoad but not working中…如果您愿意发布初始化NSMutableArray的部分,我可以查看您的代码。也许您可以“重新初始化”数组,然后将其清除?或者你(无意中)通过其他方式清除了它?