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. (:

3
  • You again?! :) Definitely keep asking questions here, but If you're new to Objective-C, I cannot recommend highly enough this book: amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619. Spend a couple hours and plow through the tutorials. It got me up to speed a few years ago on Obj-C/Cocoa in a small number of hours and was hugely beneficial. Commented Feb 9, 2010 at 17:57
  • I will get a book, the only thing is that I live in Norway, and we don't have many book stores with programming books ;) Commented Feb 9, 2010 at 18:00
  • If you can find an old copy on eBay.no or wherever, it's really worth every penny. Commented Feb 9, 2010 at 18:03

1 Answer 1

3
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).

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

4 Comments

+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.
Btw, objectsAtIndex is not valid :)
You really don't want to use -description. Use -stringValue instead.
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.

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.