问题描述
我正在尝试在两个班级之间发送数据。我已经使用properties方法完成了该操作,但是数据仍然在另一侧空着。
I'm trying to send data between two classes. I've done it using the properties method, but the data keeps coming back on the other side empty.
FrameGallery.h(正在发送数据的类):
@interface FrameGallery{
NSMutableArray *filesArray;
}
@property (nonatomic, retain) NSMutableArray *filesArray;
@end
FrameGallery.m
#import "FrameGallery.h"
@implementation FrameGallery
@synthesize filesArray;
LoadFilePopOverController.m(正在接收数据的类)
FrameGallery *frameGallery = [[FrameGallery alloc] init];
NSLog(@"%@", frameGallery.filesArray);
我在这里确实缺少某些东西吗?
Is there something that I'm missing here that's really obvious?
我过去已经成功完成了,但是找不到使用它的代码。任何帮助将不胜感激。
I've done it successfully in the past but I can't find the code where I used it. Any help would be appreciated.
推荐答案
在LoadFilePopOverController中创建一个数组并使其成为属性,然后对其进行合成。
Create an array in your LoadFilePopOverController and make it a property , synthesize it.
现在,当您从FrameGallery导航到LoadFilePopOverController时,将数组分配给在LoadFilePopOverController中创建的数组。
Now when you navigate to LoadFilePopOverController from FrameGallery , assign the array to the one that was created in LoadFilePopOverController.
例如,
在LoadFilePopOverController.h
in LoadFilePopOverController.h
NSMutableArray *getdata;
@property (nonatomic, retain) NSMutableArray *getdata;
in .m
@synthesize getdata;
现在在FrameGallery.m中,转到执行导航的代码
并将数组设置为:
Now in your FrameGallery.m , go to the code where you are performing your navigation,and set the array like:
Loadvc.getdata = filesArray;
这篇关于数据不在类之间发送-Objective-C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!