NSMutable Array from One Class to Another Class in

2019-09-11 23:36发布

I have an NSMutable Array in FirstViewController class, I want to Pass that array to SecondViewController class. And I want to use that in SecondViewController class. I am doing this in Xcode 4.2.1 with ARC... How can I...? and what are the attributes i want to use when setting property... (OR) Explain me using Appdelegate files also...

2条回答
聊天终结者
2楼-- · 2019-09-12 00:11

in current class

#import "SecondViewController"

 SecondViewController *NextViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];

        NextViewController.nextClasssArray = thisClassarray;

in second class .h

@property(nonatomic,retain) NSMutableArray *nextClasssArray;

in second class .m

@synthesize nextClasssArray;
查看更多
够拽才男人
3楼-- · 2019-09-12 00:31

There are two ways to do this.

1: Make a property for NSMutableArray in appdelegate, set the value for array in FirstViewController and retrieve value in SecondViewController.

2: Make a property for NSMutableArray in SecondViewController, and call this property for FirstViewController but making the object of SecondViewController, and calling the property via object reference of secondViewController from FirstViewController.

查看更多
登录 后发表回答