如何在UIViewControllers之间传递变量

时间:2014-07-27 22:38:11

标签: ios uiviewcontroller

我有一个Detail View Controller,它包含从Table View传递的数据:

#import "BRProjectsDetailViewController.h"

@interface BRProjectsDetailViewController ()

@end

@implementation BRProjectsDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (IBAction)unwindBackToProjectsDetailViewController:(UIStoryboardSegue *)seque;
{
    NSLog(@"unwindBackToHomeViewController!");
}

///used to feed data from homeview into detail view
-(void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"viewWillAppear");
    NSString *name = self.projects[@"name"];
    self.title = name;
    NSString *description = self.projects[@"description"];
    self.descriptionView.text = description;
}

我想把变量字符串标记为' name'上面并将其内容传递给集合视图控制器,目前在下面编码。目前,在进行调节之前,我只是想从我的NSLog获得响应。目前它只返回null :.这只是代码的摘录:任何人都可以帮忙吗?

#import "BRCollectionViewController.h"
#import "BRCollectionViewCell.h"
#import "BRProjectsDetailViewController.h"

@interface BRCollectionViewController ()
{
    ///add arrays for photos - to update once photos known
    NSArray *imagesOne;
    NSArray *imagesTwo;
}
@end


@implementation BRCollectionViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
    //added this
    NSString *name;
    NSLog(@"%@", name);
    //
}

@end

0 个答案:

没有答案