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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 07-28-2009, 10:29 AM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 4
wqin is on a distinguished road
Default problems intergrating NSURLConnection with UITableView

Hi, I'm developing an app that requires the use of NSURLConnection, which sends a request to a remote webservice, and gets xml data back.

I store the xml data into a NSData instance, and parse and transfer the data into an array of my own custom class objects. This array is managed by a UITableVIewController (which follows the tableViewDelegate and tableViewDataSource protocols), and then displayed to the UI. At the UI I have a root navigation controller, that pushes my tableViewController. All sending and fetching of xml data occurs in a method, which I call under ::viewDidAppear of my tableViewController.

I have gotten the data to appear in the table cells, but however, I cannot select my cells, nor can I press the back button on the navigation bar. (and i tried to enable selection also, but that's not it).

However, when I did not call the NSURLconnection, and initialized the data source instead with local objects, everything goes fine, and I can select my table cells and nav bar back button.

So I'm wondering, does this problem have to do with when NSURLConnection finishes? Is it a threading problem or even a view hierarchy issue? or could it be the simulator itself?

BTW: I have a login screen which is presented as a modal view over my root navigation controller. After login, the login screen is dismissed, and the navigation controller pushes right to the UITableView. Could it also be the difference between when UItableViewController's loadView and viewDidAppear are called?

I am very puzzled at this issue. If anybody could help me or offer any advice on where to start fixing this, it would be greatly appreciated.

Thanks in advance!
wqin is offline   Reply With Quote
Old 07-31-2009, 09:31 AM   #2 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 4
wqin is on a distinguished road
Default threading

I figured it out several days ago. It turns out I was using the asynchronous NSURLConnection to connect to the webservice.

Instead, I put an synchronous NSURLconnection on a NSThread I created in ViewDidAppear. The thread called 'loadEntries' method, which made the connection, and after completion, I called 'loadFinished' on the mainThread, which updated the tableView with reloadData.

[self performSelectorOnMainThread: @selector(loadFinished) withObject:nil waitUntilDone:NO];
wqin is offline   Reply With Quote
Reply

Bookmarks

Tags
nsurlconnection, uinavigationbar, uitableview, uitableviewcontroller, viewdidappear

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: 366
9 members and 357 guests
.Snipe, BSH, Cee Oasis, givensur, guusleijsten, HemiMG, NSString, Paul Slocum, SillyHoney
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,645
Threads: 94,111
Posts: 402,862
Top Poster: BrianSlick (7,990)
Welcome to our newest member, leighec68
Powered by vBadvanced CMPS v3.1.0

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