views:

18

answers:

1

Hi,

I have the following code:

Product product = [[Product alloc] init];
product.title = tag; 
[allProducts addObject:product];
NSString *pImage = [[NSString alloc] initWithFormat:p.title];

But it is failing to return anything

Can anyone kindly help me please? THanks

+1  A: 

Nothing in your code is trying to retrieve anything from a collection.

[allProducts addObject:product];

The line above is used for adding objects. If you are looking to retrieve an object you do:

Product* product = [allProducts objectAtIndex:0];

Look at the documentation for NSArray and NSMutableArray.

--update--

Just noticed you have an error in your code:

Product* product = [[Product alloc] init];

(you left out the *)

willcodejavaforfood
and you just added an extra `]` :)
Toastor
@Toastor - OOOOOOOOOOOOOOPS :)
willcodejavaforfood