Hi,
I'd consider myself a beginner at iPhone development, but I do have a reasonably solid understanding of how the basics work.
I'm working on an app which reads through an XML file on the internet - the file I'm using for testing purposes: http://www.w3schools.com/xml/note.xml
As it processes the contents of each element, it stores each piece of information (to, from, heading, body) in a separate ivar, and when it reaches the end of the <note> element, it creates an array from these 4 variables, and adds the array to an NSMutableArray (allNotes) which is an instance variable of the class.
-(void) listNoteDetails is called to log the details of the notes:
The problem I'm having is if I call listNoteDetails from the method
which is implemented in the same class, it all works fine. However I want to be able to log these details by pressing a button. As soon as I change listNoteDetails to an IBAction and connect it to a button, it causes the app to crash when the button is pressed - this occurs whenever something in the listNoteDetails method tries to access the allNotes ivar. Can anyone explain why this happens?
I hope my description of the problem makes some sense.
Thanks.
I'd consider myself a beginner at iPhone development, but I do have a reasonably solid understanding of how the basics work.
I'm working on an app which reads through an XML file on the internet - the file I'm using for testing purposes: http://www.w3schools.com/xml/note.xml
As it processes the contents of each element, it stores each piece of information (to, from, heading, body) in a separate ivar, and when it reaches the end of the <note> element, it creates an array from these 4 variables, and adds the array to an NSMutableArray (allNotes) which is an instance variable of the class.
-(void) listNoteDetails is called to log the details of the notes:
Code:
-(void) listNoteDetails
{
for(NSArray *note in allNotes)
{
NSString *to = [note objectAtIndex:0];
NSString *from = [note objectAtIndex:1];
NSString *heading = [note objectAtIndex:2];
NSString *body = [note objectAtIndex:3];
// Code to log details here
}
}
The problem I'm having is if I call listNoteDetails from the method
Code:
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
[self listNoteDetails]
}
which is implemented in the same class, it all works fine. However I want to be able to log these details by pressing a button. As soon as I change listNoteDetails to an IBAction and connect it to a button, it causes the app to crash when the button is pressed - this occurs whenever something in the listNoteDetails method tries to access the allNotes ivar. Can anyone explain why this happens?
I hope my description of the problem makes some sense.
Thanks.