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

iOS programming help

Hello. I am trying to figure out this problem for a Homework assignment I have and I can't seem to get it. Can someone help me just a bit so I understand this. I've been trying to figure it out all day.. Thank you very much.

@property (nonatomic, assign) BOOL getsDiscount;

/** Indicates which item Mary can purchase, given an amount of dollars.

See MarysAppleHandlerTests for all expected results.

Example usage:

@code NSString *itemPhrase = [handler itemMaryCanPurchaseForDollars:7]; // itemPhrase is "have an apple". @endcode

@param dollars The most amount of money that Mary is able and willing to spend

@return Returns an item phrase.


import "MarysAppleHandler.h"

@implementation MarysAppleHandler

  • (NSString ) itemMaryCanPurchaseForDollars:(NSInteger)dollars { NSString *itemToReturn; / WORK HERE */

    NSLog(@"For $%ld, Mary can: %@", (long)dollars, itemToReturn); return itemToReturn; }

  • (NSUInteger) dollarCostForAppleFlavoredVodka { /* WORK HERE */

    NSUInteger cost = 24;

    if (self.getsDiscount) { cost *= .75; }

    return cost; }

@end