i have an UITableView and im trying to return the number of rows using [arrayName count] however when i run the application it seems to be crashing with no errors showing in console. Here is some code .. (also when i test the array in ViewDidLoad using NSLog, it does return '16' so im not sure why it crashes when i do the row count. Thanks ..
3 Answers
I think the problem is in this line:
elements = [xpathParser search:@"//div[starts-with(@id,'content_div')]//a"];
I guess the - search method returns an autoreleased object, so that your elements object receives the release message after the method viewDidLoad returns and hence gets deallocated.
You can fix this in two ways:
add a
retaincall, like thiselements = [[xpathParser search:@"//div[starts-with(@id,'content_div')]//a"] retain];use properties, like this
self.elements = [xpathParser search:@"//div[starts-with(@id,'content_div')]//a"];