tags:

views:

41

answers:

2
groupContentList = [[NSArray alloc] initWithObjects:
        [Product productWithType:@"Device" name:@"iPhone"],
        [Product productWithType:@"Device" name:@"iPod"],
        [Product productWithType:@"Device" name:@"iPod touch"],
        [Product productWithType:@"Desktop" name:@"iMac"],
        [Product productWithType:@"Desktop" name:@"Mac Pro"],
        [Product productWithType:@"Portable" name:@"iBook"],
        [Product productWithType:@"Portable" name:@"MacBook"],
        [Product productWithType:@"Portable" name:@"MacBook Pro"],
        [Product productWithType:@"Portable" name:@"PowerBook"], nil];

How to print the value of groupcontestList

+1  A: 
For(Product* prod in groupContent){
    NSLog(@"type=%@ name=%@", prod.type, prod.name);
}
Morion
+4  A: 

You can retrieve a string representing NSArray contents with -description method. This is implicitely used with:

NSLog(@"%@", groupContentList);

It will in turn invoque -description method on each of its elements (which defaults to printing address of object as defined in NSObject).

So if you want it to be usable, you have to define a -description method for your Product class.

mouviciel