2 つのビュー コントローラー間で NSMutableArray を渡そうとしています。このために何ができるか教えてください
私が持っているPlaylistViewController.hファイルで
NSMutableArray *SongArray;
@property(nonatomic,retain)NSMutableArray *SongArray;
別のView Controllerに渡したい
2 つのビュー コントローラー間で NSMutableArray を渡そうとしています。このために何ができるか教えてください
私が持っているPlaylistViewController.hファイルで
NSMutableArray *SongArray;
@property(nonatomic,retain)NSMutableArray *SongArray;
別のView Controllerに渡したい
配列を渡したいView Controllerを元のView Controllerのデリゲートとして設定できます(あなたの場合はPlaylistViewController)
**OriginViewController.h**
@protocol OriginViewControllerDelegate {
-(void)passMutableArray:(NSMutableArray*)array;
}
@interface OriginViewController : UIViewController
@property(nonatomic,retain)id<OriginViewControllerDelegate> delegate;
@property(nonatomic,retain)NSMutableArray *array;
**OriginViewController.m**
//set DestinationViewController as delegate to OriginViewController(not necessarily in OriginViewController.m
//When you want to pass array just send message to delegate
[self.delegate passMutableArray:array];
**DestinationViewController.h**
@interface DestinationViewController : UIViewController <OriginViewControllerDelegate>
//implement protocol function in your m file
**DestinationViewController.m**
-(void)passMutableArray:(NSMutableArray*)array {
//Do whatever you want with the array
}