Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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-26-2009, 06:05 AM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 25
Default XML Parser Help

Hey everyone,

Wonder if a little guidance could be offered, I had my first app bundle all ready and zipped to go when I was playing around with my so called finished product on my device when I found a rather major bug which causes my app to crash before its even finished loading.

I thought I got this glitch in my code with:

Code:
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
	NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
	NSLog(@"error parsing XML: %@", errorString);
	
	UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content, please check data connection" message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
	[errorAlert show];
	
	[errorAlert release];
}
However currently all I get is that the app hangs on the default slapsh screen and the screen does the dimming halo effect as if an alert window is going to be displayed but then in console the app terminates with the following error:

-[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)'

now I understand that basically it is carrying on through the code not pausing for the user to select "OK" after which I could set the action to terminate the program, it is then reaching the first point in the code where an array is sourced from which obvioulsy doesn't exsist or hasn't been populated yet..

I read that there is no real system pauses as its been written out.. has anyone got any suggestions of what avenue to go down to halt the progress of the app and kill it on the user input of OK as there is no network coverage etc.. rather than terminating itself from an uncaught exception.

I hope I made sense..

Any help appreciated,

Peter
peterbrowse is offline   Reply With Quote
Old 06-26-2009, 06:47 AM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Jacksonville, FL
Posts: 58
Default Event driven

Perhaps you should show this dialog like you are and use another method of the NSXMLParser to continue your application if it is available.

- (void)parserDidEndDocumentNSXMLParser *)parser

What causes your app to move forward and try to use the array now?

Until this method is called perhaps you should just present a UIActivityIndicatorView.
timle8n1 is offline   Reply With Quote
Old 06-26-2009, 07:16 AM   #3 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 25
Default

Quote:
Originally Posted by timle8n1 View Post
Perhaps you should show this dialog like you are and use another method of the NSXMLParser to continue your application if it is available.

- (void)parserDidEndDocumentNSXMLParser *)parser

What causes your app to move forward and try to use the array now?

Until this method is called perhaps you should just present a UIActivityIndicatorView.
I managed to fix it by setting the array that was in question to 0 if it passed through the error function which meant that it could pass through the entire loading function then report no connection, alert view displays correctly now.

Thanks for your thoughts though
peterbrowse is offline   Reply With Quote
Reply

Bookmarks

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


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 329
23 members and 306 guests
cakeisalie, dbonates, dennisdeo, Ed99, gullyben, Hololont, iBud, irishkiwi, JasonR, lepetitapps, muteon, OpenDoorApps, pengcognito, phuongth, RamSundar, rendezvouscp, robmonty, saidev, sfeast, shuvo1879, tpearce, vertine
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,327
Threads: 39,123
Posts: 171,541
Top Poster: smasher (2,577)
Welcome to our newest member, tpearce
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:22 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0