Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / July 2005



Tip: Looking for answers? Try searching our database.

Why do i get this error?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nob - 27 Jul 2005 03:19 GMT
can someone help me, y do i get this error?
===============================================
2005-07-27 09:55:19.605 tryXML[345] An uncaught exception was raised
2005-07-27 09:55:19.610 tryXML[345] *** -[NSCFArray objectAtIndex:]:
index (1) beyond bounds (0)
2005-07-27 09:55:19.613 tryXML[345] *** Uncaught exception:
<NSRangeException> *** -[NSCFArray objectAtIndex:]: index (1)
beyond bounds (0)

tryXML has exited due to signal 5 (SIGTRAP).

below is my code
===============================================
NSXMLNode *aNode =[xmlDoc rootElement];
NSMutableArray *arr = [NSMutableArray array];

aNode = [aNode nextNode];
aNode = [aNode childAtIndex:13];
int i;

arr = [NSMutableArray arrayWithObjects: nil];

for(i = 0; i <= 1; i++){
aNode = [aNode childAtIndex:1+i];
aNode = [aNode childAtIndex:1];
[arr addObject:[NSString stringWithString:[aNode stringValue]]];
}//end for
[node1 setStringValue:[arr objectAtIndex:0]];
[node2 setStringValue:[arr objectAtIndex:1]];
===============================================

is there sth wrong with my array? :(

* posted via http://www.mymac.ws
* please report abuse to http://xinbox.com/mymac
Ulrich Hobelmann - 27 Jul 2005 09:27 GMT
> arr = [NSMutableArray arrayWithObjects: nil];

empty array, I would call [NSMutableArray array] here I think.
(or [NSMutablearray arrayWithObject: nil]) if that's what you mean.

> for(i = 0; i <= 1; i++){
> aNode = [aNode childAtIndex:1+i];
> aNode = [aNode childAtIndex:1];
> [arr addObject:[NSString stringWithString:[aNode stri

array with one object.

ngValue]]];
> }//end for
> [node1 setStringValue:[arr objectAtIndex:0]];
> [node2 setStringValue:[arr objectAtIndex:1]];

I guess it's the above line that fails?  You might want to try it
out in the XCode debugger.

Signature

XML is a prime example of retarded innovation.
    -- Erik Meijer and Peter Drayton, Microsoft Corporation

David Phillip Oster - 27 Jul 2005 16:37 GMT
> can someone help me, y do i get this error?

> 2005-07-27 09:55:19.610 tryXML[345] *** -[NSCFArray objectAtIndex:]:
> index (1) beyond bounds (0)
...
> aNode = [aNode childAtIndex:1+i];

how many children does aNode have?

Signature

David Phillip Oster

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.