0

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
  • should be Product* product = [[Product alloc] init]; Commented Sep 24, 2010 at 15:45

1 Answer 1

1

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 *)

Sign up to request clarification or add additional context in comments.

2 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.