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 trialStevan Relic
798 PointsQuestion 3 of this Challenge, shoppingCart = [shoppingList objectAtIndex:2]; is a mistake?
I get the system saying that I should remember that arrays start at 0, well if eggs is the 3rd array object then I should invoke object 2.
I think the error is in my syntax, could you help? I had a similar issue on question 2 as it is not the same syntax as in the video.
#import "UIViewController.h"
@interface ViewController : UIViewController
@property (strong, nonatomic) NSString *shoppingCart;
@end
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Add your code below!
}
@end
Stevan Relic
798 PointsYes, of course,
Q1: @property (strong, nonatomic) NSSArray *shoppingList; //This one was OK Q2: self.shoppingList = @[@"toothpaste", @"bread", @"eggs"]; //This one was OK Q3: shoppingCart = [shoppingList objectAtIndex:2]; // This one is wrong
Thanks a lot for your help!!!
1 Answer
Russell Warwick
1,601 PointsOkay so it looks like you need to call <p> self.shoppingCart=[self.shoppingList objectAtIndex:2]; </p>
Stevan Relic
798 PointsHi Russell, Thanks a lot for your help. That worked, did not see the self.shoppingList had to be there!!
Russell Warwick
1,601 PointsRussell Warwick
1,601 PointsCould you provide the code that you entered?