Challenge question assistance needed


#1

I did the challenge to what I believe is acceptable, but I wanted to go one step more.

I wanted to truly separate the entries in the arrays so only the entries that have a value over 50 would go into that array and the same for the under 50 array. How can I accomplish this? There must be a quick and easy solution that I’m not seeing.

I tried several different things and I did some research on the net, but I can’t seem to come up with anything concrete. I feel like I get close, but not close enough.


#2
NSMutableArray *expensivePossessions = [[NSMutableArray alloc] init];
NSMutableArray *cheapPossessions = [[NSMutableArray alloc] init];
for(int i = 0; i < 10; i++)
{
    Possession *p = [Possession randomPossession];
    if([p valueInDollars] > 50)
            [expensivePossessions addObject:p];
    else
            [cheapPossessions addObject:p];
}

#3

Thanks! I’m not sure why I didn’t see that easy solution. Perhaps my brain was tired from working towards learning Objective-C so quickly! :confused: