选择的项目是滑块。当我点击滑块时,它将向第二个VC(WebViewController)传递数据。但是如何从第一个视图控制器传递数据到第二个视图控制器在objective-c中?抱歉,这是我第一次编写objective C代码。
第一个VC .m文件
第一个VC .m文件
#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];
}..
第二个VC .m文件
@interface WebViewController ()
@property (nonatomic, retain) NSString *data;
第二个 VC .h 文件
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController
{
AppDelegate *appDelegate;
NSString *data;
}
@end
.h
文件代码吗? - undefined