I have search functionality on books, and I get 25 books at a time, even if the search criteria could be a total above 25. So I add a Get More button, the user selects to get the next 25.
I am also showing the books in a grid view.
So I am creating an NSMutableArray and putting in BookViewControllers or the GetMoreViewController. This array constitutes a row of books.
Anyway, for some reason when debugging, I will see other object types in this array and there shouldn't be. Funny thing is that will happen after hitting the get more button a few times. Meaning 25 books returned. Hit get more, get the next 25, hit get more, gets the next 25, hit get more, exception where there is an odd object type. Like once I saw an NSDictionary, in another I saw a CFXString or something like that.
Code:
NSMutableArray *bookViewControllers = [[[NSMutableArray alloc] init] autorelease];
//Could there be a calculation problem here
for (int i=0; i< numberOfColumns; i++) {
if ([books count] > firstBook) {
SingleBookInSearchViewController *bookSubView = [[SingleBookInSearchViewController alloc] initWithNibName:@"SingleBookInSearchView" bundle:nil];
bookSubView.appContainerViewController = self.appContainerViewController;
bookSubView.book = [books objectAtIndex:firstBook];
[bookViewControllers addObject:bookSubView];
[bookSubView release];
} else {
if (stateHolder.currentMode < BOOK_MODE) {
if (appContainerViewController.bookViewStateHolder.totalCountForSearch >
appContainerViewController.bookViewStateHolder.lastCountForSearch) {
// Need to add the GetMoreBooks
GetMoreBooksViewController *moreBooks = [[[GetMoreBooksViewController alloc] initWithNibName:@"GetMoreBooksView" bundle:nil] autorelease];
moreBooks.detailViewController = self;
[booksViewControllers addObject:moreBooks];
break;
}
}
}
firstBook++;
}
[cell setBooks:bookViewControllers];
Thanks
Mark