Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!