Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-30-2009, 01:31 PM   #1 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 355
Exclamation Help with loading text into a tableview from an array

hey people im having trouble with loading my array of strings into a tableview , what i have already done is read in information from an xml file and stored the data i need into an array of elements called title, now what i want to do is load up the titles into the table view so the user can choose one of the option and move forward from there , now my problem is that when i load up the table view it comes up blank, i ran the program through the debugger and what is happening is after the program runs the view did load method it jumps straight into the functions to setup the tableView, now my question is is there a way for me to manipulate the program so that all the information gets parsed before the tableview gets loaded up and then load up the tableview and see all the data i need to display into the cell?
Esko2300 is offline   Reply With Quote
Old 06-30-2009, 02:35 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 157
Default

Quote:
Originally Posted by Esko2300 View Post
is there a way for me to manipulate the program so that all the information gets parsed before the tableview gets loaded up and then load up the tableview and see all the data i need to display into the cell?
I don't want to be rude at all, but I really think you could have found the answer to this question by googling "load tableview iPhone" but I will tell you anyway .

The table view will get loaded when the view is loaded which is totally fine, because the cells get loaded separately and it is in the cells that you want to take the values from your array and display them.

Soo...... If you have an array "myArray" then you would implement this to load the data in each cell

Code:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

NSUInteger row = [indexPath row];

static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SectionsTableIdentifier];

if ( cell == nil ) {
cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SectionsTableIdentifier] autorelease];
}

cell.textLabel.text = [myArray objectAtIndex:row];
return cell;

}
Also, myArray must be your array of NSStrings.
JCooperman is offline   Reply With Quote
Old 06-30-2009, 02:49 PM   #3 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 355
Exclamation Already have that

i already have the code u posted in my code , what i did was placed breakpoints in all the functions i have in my code and when it starts it goes from viewDidLoad to the numberOfRowsInSection method which is supposed to count the amount of objects in the array, only problem is when i check whats in the array when numberOfRowsInSection executes the array is empty , its because the parser is running after this method is called and since the znumberOfRowsInSection is not returning an integer it never executes the cellForRowAtIndexPath method. how can i load up the xml file and read it into the array before i place the values into the table?
Esko2300 is offline   Reply With Quote
Old 06-30-2009, 03:07 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 157
Default

1. Fill the array in the viewDidLoad method

2. Then the numberOfSections: method should be:

return 1;

3. Then the numberofRows: method should be:

return [myArray count];

Try that, parse the values into an array in the viewDidLoad method. (That should be obvious if your array was not loaded when you set breakpoints???)
JCooperman is offline   Reply With Quote
Old 06-30-2009, 03:31 PM   #5 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 355
Default

sdf

Last edited by Esko2300; 07-24-2009 at 11:11 AM.
Esko2300 is offline   Reply With Quote
Old 02-07-2010, 10:53 AM   #6 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 16
Posts: 1,292
Default

I did a tutorial on the UITableView using a NSMutableArray. link
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Reply

Bookmarks

Tags
uitableview, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 259
23 members and 236 guests
ADY, AragornSG, bookesp, chillyh, dacapo, Dani77, Davey555, Desert Diva, Dominus, glenn_sayers, HemiMG, JasonR, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, Oral B, prchn4christ, Raggou, Rudy, themathminister
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:31 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0