我试图在两个视图控制器之间传递一个 NSMutableArray.请让我知道我可以为此做些什么
I am trying to pass a NSMutableArray between two view controller. Please let me know what can i do for this
在我的 PlaylistViewController.h 文件中
In the PlaylistViewController.h file I have
NSMutableArray *SongArray;
@property(nonatomic,retain)NSMutableArray *SongArray;
我希望传递给另一个视图控制器
which I wish to pass to another view controller
你可以通过两种方式分享:
You can share in two ways:
示例
在 .h 文件中
@interface ABCController : UIViewController
{
NSMutableArray *detailArray;
}
@property(nonatomic,retain)NSMutableArray *detailArray;
在 .m 文件中
XYZController *xyzVC = [[XYZController alloc] initWithNibName:@"XYZController" bundle:nil];
xyzVC.detailArray = self.detailArray;
[self.navigationController pushViewCsecondView:xyzVC animated:YES];
**XYZController.h**
@interface XYZController : UIViewController
{
NSMutableArray *detailArray;
}
@property(nonatomic,retain)NSMutableArray *detailArray;
NSUserDefaults
示例
[[NSUserDefaults standardUserDefaults] setValue:SongArray forKey:@"songArray"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSMutableArray *arr = [[NSUserDefaults standardUserDefaults] valueForKey:@"songArray"];
这篇关于将 NSMutableArray 传递给一个视图控制器到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!