我有两个类。首先下载数据映像并将它们逐个添加到阵列中。当它完成后,所有16个人都会将视图切换到第二个视图。我的问题在于如何从第二课的第一课访问数组?从不同的视图控制器访问阵列
下面是代码:
first.h
@interface first{
NSMutableArray *imagesArray;
}
@property(nonatomic,retain)NSMutableArray *imagesArray;
(阵列在.m文件synthetized)
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时,传递该数组。所以你不需要分配第一个视图。 – 2014-09-02 04:19:59
http://stackoverflow.com/questions/6678097/how-to-pass-an-array-from-one-view-controller-to-another和http://stackoverflow.com/questions/15789163/add-objects从另一个视图控制器到阵列可能会有所帮助 – 2014-09-02 04:31:50