Amazon.com Widgets Textview Help!!!
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 19, 2013, 06:32:20 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Help!!!
| | |-+  Textview Help!!!
Pages: [1]   Go Down
Print
Author Topic: Textview Help!!!  (Read 456 times)
atothendrew
Newbie
*
Posts: 1


Email




« on: June 27, 2009, 12:31:59 PM »

I'm trying to display my array "main_array" into a textview. but when i do, i only get the number in the last array slot.

Code: (Objective-C)
for(x=0;x<=size_int;x++)
{
main_array[x] = (rand() % max_int) + 1;
textview.text =[NSString stringWithFormat:@"myNumber: %i\n", main_array[x]];
}

for some reason it erases itself each time the loop is processed.

could i do something like:
Code: (Objective-C)
textview.text = textview.text[NSString stringWithFormat:@"myNumber: %i\n", main_array[x]];

any ideas? suggestions? i really need help...

Logged
esc
Global Moderator
Full Member
*****
Posts: 230






« Reply #1 on: June 27, 2009, 12:58:17 PM »

How do you declare main_array?  Is it a C-style array of type double or is it an NSMutableArray?
Logged
skochan
Administrator
Hero Member
*****
Posts: 3109







« Reply #2 on: June 27, 2009, 01:35:21 PM »

It seems like you're  overwriting the text field each time through the loop with the next array element.  So by the end of the for loop, all you have is the last entry in the entry to display.  Perhaps you want to build up a single string by using the stringByAppendingString: method so that you concatenate each successive element to the end of a string each time through the loop.  Then once the loop is over you can display the resulting string.

Anyway, that's just my take on what I think you're trying to accomplish.

Cheers,

Steve Kochan
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.