views:

55

answers:

1

How can you return an array value (witch is a number) as a string?

Current code:

return [numbers objectAtIndex:row];

Have also tried:

return @"%@", [numbers objectAtIndex:row];

With no luck..

Thanks :) PS: Yes, I am stupid. (:

+2  A: 
return [[numbers objectAtIndex:row] description];

In C / ObjC / C++ / Javascript / D / many other C-based languages, the comma operator does not create an array / tuple.

(a,b,c,d,e)

is similar to

e

(while evaluating a and b and c and d as a side-effect).

KennyTM
Ah, okay, thanks :)
Emil
+1 for talking about the unloved comma operator. But beware newbies that we don't write `(a, b, c, d, e)` almost ever in C languages.
quixoto
Btw, object**s**AtIndex is not valid :)
Emil
You really don't want to use `-description`. Use `-stringValue` instead.
bbum
@bbum Why?-----
Emil
Because -description is a method that is intended to describe an object in a debugging or logging role. -stringValue is intended for purposes of display and the like.
bbum