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) Refactoring into a Model Creating a Custom Class

valentin bancarel
valentin bancarel
4,459 Points

I'm lost ...

I follow that course but i'm french so i don't understand everythings good but I have some skills in objective developement (C#), here is my code the same at the example I think but it don't works and I don,t know why:

quote.h
@interface Quote : NSObject{
    NSArray *_quotes;
}

@property (strong,nonatomic,readonly) NSArrayv *quotes;

- (NSString*) randomQuote;

@end



quote.m
#import "Quote.h"

@implementation Quote

-(NSArray *) quotes{
if(_quotes == nil){
        _quotes = [[NSArray alloc ] initWithObjects:@"1", @"1", @"1", nil ];
  }
  return _quotes;
}

- (NSString *) randomQuote {    
    return @"Some Quote";
}

@end

Editor tell me: Remember to allocate and initialize the instance variable '_quotes' and return it from the method named 'quotes'. bt it is not ? Thanks for help

2 Answers

Paul Panayotou
Paul Panayotou
5,001 Points

One thing is that there's a 'v' in your quotes property which shouldn't be there

Stone Preston
Stone Preston
42,016 Points
quote.h
@interface Quote : NSObject{
    NSArray *_quotes;
}

@property (strong,nonatomic,readonly) NSArrayv *quotes;

- (NSString*) randomQuote;

@end

you dont need that *_quotes instance variable. the property creates that for you behind the scenes. also remove the v off the end of NSArray. Other than that everything looks good.