Nathan
Nathan

Reputation: 151

What does it mean by references?

I'm taking a tutorial for X-code that says this:

"Go into the code and change the references from DrinkArray to DrinksDirections."

What exactly does it mean?

I would show you the tutorial, except it's a book that costs money.

The only reference I found of DrinkArray is:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"DrinkArray" ofType:@"plist"];
    NSMutableArray* tmpArray = [[NSMutableArray alloc] initWithContentsOfFile:path];
    self.drinks = tmpArray;
    [tmpArray release];
        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

Upvotes: 1

Views: 234

Answers (4)

Nathan
Nathan

Reputation: 151

okay, I figured it out. It wasn't DrinkDirections, it was DrinksDirections. It's stupid that a little thing can mess up a whole program.

Upvotes: 0

Paul Alexander
Paul Alexander

Reputation: 32367

This is from Head First iPhone Development. The code in viewDidLoad that you found is where you want to make the change:

NSString *path = [[NSBundle mainBundle] pathForResource:@"DrinkArray" 
                                        ofType:@"plist"];

This line basically asks for the file path to the DrinkArray.plist bundled with the application. In the tutorial the next step is to migrate to a dictionary based array where each element contains a name, ingredients and directions.

Rather than typing out each entry by hand, they've provided a copy of the updated plist named DrinkDirections.plist in the book downloads. After downloading the sample files, copy the DrinkDirections.plist into your project Resources folder. Then change the line in viewDidLoad to

NSString *path = [[NSBundle mainBundle] pathForResource:@"DrinkDirections" 
                                        ofType:@"plist"];

This asks for the path to the DrinkDirections.plist that you've just added to your project. Be aware that your application will crash after making this change - that's OK, it's part of the tutorial and is covered in the immediately following pages.

Upvotes: 1

Chuck
Chuck

Reputation: 237060

"Reference" is not a precise technical term in Objective-C, so what it means is whatever the author meant was thinking of when he wrote it. The term is sometimes used in "passed by reference" or "returned by reference," in which case "reference" means "pointer" — but that doesn't seem to be the usage here. Most likely the tutorial means to change places where your code mentions "DrinkArray" to instead say "DrinksDirections."

Upvotes: 1

Amir Afghani
Amir Afghani

Reputation: 38541

The type of some declared reference variable is DrinkArray. It's telling you to change the type to DrinksDirection. Can you paste the code snippet?

Upvotes: -1

Related Questions