0

I have a Detail View Controller which contains data passed from a 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;
}

I want to take the variable string labelled 'name' above and pass the contents of this to a collection view controller, currently coded below. At the moment, before doing conditioning I'm just trying to get a response from my NSLog. Currently it just returns null: . This is just an excerpt from the code: Can anyone help please?

#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
modusCell
  • 13,151
  • 9
  • 53
  • 80
  • 1
    possible duplicate of [Passing Data between View Controllers](http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – Hot Licks Jul 27 '14 at 22:53
  • How do you expect `name` to have a value other than `nil`? It's an uninitialized local variable. – rmaddy Jul 27 '14 at 23:41
  • Oops - I restored back to previous version. I've done that and it made no difference. I've found what I believe is a working example using a singleton . I'll try that . Also , the variable name isn't null in the projects detail controller. It holds the value from table view . So are you telling me to re initialise in collection view? Help appreciated.... – user3882242 Jul 28 '14 at 07:03

0 Answers0