PDA

View Full Version : NSarray




BollywooD
Dec 28, 2009, 06:23 AM
probably a simple question, but....
I have an NSArray, which when i check it contents:

NSLog(@"myArray: %@", myArray);


it looks like this:
myArray: (
"<Info: 0x118a9c740>",
"<Info: 0x1192f8880>"
)

how can I see what is contained in the Array?

thanks in advance:confused:



robj
Dec 28, 2009, 06:30 AM
You can override the description method of the objects of you array.

BollywooD
Dec 28, 2009, 06:33 AM
how exactly would i do that?

robj
Dec 28, 2009, 06:36 AM
how exactly would i do that?

Simply add to your class a method called description:
-(NSString *) description {
return @"whatever you want";
}

And NSLog would call it to print the info

BollywooD
Dec 28, 2009, 07:11 AM
I hate to say it but im still lost....

Ive been looking at code ALL day

kainjow
Dec 28, 2009, 07:35 AM
Every Cocoa object has a built-in description method that returns a string describing that object. By default Cocoa provides a basic description, but you can override that method to return something that is clearer. When you NSLog an array, it spits out the result of this method for every object in the array. So in your Info class, you would override the method and possibly return a combination of the important ivars in that class (using for example NSString's stringWithFormat to generate the string).