【发布时间】:2014-09-02 03:47:59
【问题描述】:
我有两节课。第一个下载数据图像并将它们一个接一个地添加到数组中。当所有 16 个都完成后,运行将视图切换到第二个的操作。我的问题是如何从二等的一等访问数组?
代码如下:
first.h
@interface first{
NSMutableArray *imagesArray;
}
@property(nonatomic,retain)NSMutableArray *imagesArray;
(数组在.m文件中合成)
second.h
#import"second";
#import"first.h"
second.m
-(void) viewdidload {
first *another = [[another alloc] init];
label.text = [NSString stringWithFromat:@"%i",[another.imagesArray count]];
imageView.image = [another.imagesArray objectAtIndex:0];
}
label 显示 0 而imageView 什么也不显示。有什么想法吗?
【问题讨论】:
-
您可以创建全局数组或在 second.h 中定义相同的
@property(nonatomic,retain)NSMutableArray *imagesArray;,当您从 First 推送到 Second 时,然后传递该数组。所以你不需要分配第一个视图。