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 (iOS7) Creating a Data Collection Create an NSArray Property

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

This code challenge seems to be contradicting it self.

Can anyone figure out whats wrong?

Here is what the preview says: too many arguments to method call, expected 1, have 4

 self.quotes = [[NSArray alloc] initWithObject:@"Haters gonna hate", @"Life is simple, not easy", @"Winners never quit, quitters never win", nil];
THViewController.h
#import "UIViewController.h"
#import "UILabel.h"

@interface THViewController : UIViewController

@property (nonatomic, strong) IBOutlet UILabel *quoteLabel;
@property (nonatomic, strong) NSArray *quotes;
@end
THViewController.m
#import "THViewController.h"

@implementation THViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Add your code below! 
    // Remember the array property is called 'quotes'
    // And the label property is called 'quoteLabel'
    self.quotes = [[NSArray alloc] initWithObject:@"Haters gonna hate", @"Life is simple, not easy", @"Winners never quit, quitters never win", nil];    



}

@end

5 Answers

Lee Watkins
Lee Watkins
11,345 Points

The first problem I can see is that your array declaration should be:

[[NSArray alloc] initWithObjects:@"Haters gonna hate", @"Life is simple, not easy", @"Winners never quit, quitters never win", nil];

You've left the 's' off initWithObjects

This should give a different error because there is no initWithObject: function, but try this out and let us know.

Eduardo Rojas
Eduardo Rojas
4,084 Points

i think you are missing a bracket "{}" after "@implementation THViewController <- {"

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

Okay Lee, fixed what you said and from what I can tell the rest is all the same, but now it (the preview) says that I'm missing the end box bracket and I'm not. Any tips?

Lee Watkins
Lee Watkins
11,345 Points

Hi Caleb

I've gone back to the code challenge and run your code exactly as it is (with the added s) and it works - I don't get anything on the preview. It should be working now - as I say, I've copied and pasted and it runs.

If you still aren't sorted, could you post your updated code?

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

Not sure what was wrong, I tried it again today and it worked. Thanks!