Data not sending between classes - Objective-C

2019-09-10 10:31发布

问题:

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 (class that's sending data):

@interface FrameGallery{
    NSMutableArray *filesArray;
}

@property (nonatomic, retain) NSMutableArray *filesArray;

@end

FrameGallery.m

#import "FrameGallery.h"

@implementation FrameGallery

@synthesize filesArray;

LoadFilePopOverController.m (class that's receiving data)

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.

回答1:

Create an array in your LoadFilePopOverController and make it a property , synthesize it.

Now when you navigate to LoadFilePopOverController from FrameGallery , assign the array to the one that was created in LoadFilePopOverController.

For e.g.

in LoadFilePopOverController.h

NSMutableArray *getdata;

@property (nonatomic, retain) NSMutableArray *getdata;

in .m

@synthesize getdata;

Now in your FrameGallery.m , go to the code where you are performing your navigation, and set the array like:

Loadvc.getdata = filesArray;