The select item is a slider. When I click the slider It will pass the data to Second VC (WebViewController). but how to pass data from first view controller to second view controller in objective-c? Sorry, This is my first time coding objective C.
First VC .m file
#import "WebViewController.h"
- (void)viewDidLoad {
[super viewDidLoad];
arraySliderProducts = [[NSMutableArray alloc]init];
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
UIViewController *controller = nil;
switch (indexPath.row)
{
case 0:
{
WebViewController *WebViewController = [[WebViewController alloc] init];
//error: No visible @interface for "WebViewController" declares the selector 'alloc'
WebViewController.data = arraySliderProducts[indexPath.row][@"title"]; //pass this link value
//error: Property 'data' not found on object of type 'WebViewController'
[self.navigationController pushViewController: WebViewController animated:YES];
}..
Second VC .m file
@interface WebViewController ()
@property (nonatomic, retain) NSString *data;
Second VC .h file
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController
{
AppDelegate *appDelegate;
NSString *data;
}
@end