Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Simple iPhone App with Objective-C Creating a Data Model Creating a Data Collection

Christian Johansson
Christian Johansson
1,772 Points

self

I can't seem to get this to work, have tried a lot of stuff and checked internet but it says everything I insert is wrong.

ViewController.h
#import "UIViewController.h"

@interface ViewController : UIViewController

@property (strong, nonatomic) NSString *shoppingCart;

@property (nonatomic, strong) NSArray *shoppingList;

@end
ViewController.m
#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Add your code below!
    self.shoppingList = [@"toothpaste", @"bread", @"eggs"];
}

@end

1 Answer

Christian, it seems that you have working code but there is one thing you left out in the implementation. When you assign the array some items, you forgot the @ symbol before the first square bracket.

Here is the correct implementation:

ViewController.h
#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Add your code below!
    self.shoppingList = @[@"toothpaste", @"bread", @"eggs"];

@end

Christian, no problem! Even after months of programming, I still make syntax mistakes every day! I am glad that I could help!