Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 08-07-2010, 02:13 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default Odd object types in my Array

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
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html

Last edited by bytor99999; 08-07-2010 at 02:45 PM.
bytor99999 is offline   Reply With Quote
Old 08-07-2010, 02:21 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You are over-releasing moreBooks.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 08-07-2010, 02:39 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Quote:
Originally Posted by BrianSlick View Post
You are over-releasing moreBooks.

Thanks Brian. But that actually wasn't there before, I added it to see if that fixed my problem. Which of course it didn't. Funny thing is the index in the array that should be the booksViewControllers is where I get odd object types, the getMoreViewController is always the last object in the array and correct.

This problem also seems to be a timing thing, If I debug where it stops on the get more adding to the array and I check to see the object types in the array, then play, then click the get more, and continue for as long as it should take to have this problem, it does not happen.

If I don't break on that line and let it run normally and the user scrolls fast, then clicks the Get more button, after a little bit it happens.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Old 08-07-2010, 02:43 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Try posting the actual code you want help with then. Nothing like wasting time with a wild goose chase.

Symptoms sound like a memory problem. Something autoreleased, probably.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 08-07-2010, 02:45 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Quote:
Originally Posted by BrianSlick View Post
Try posting the actual code you want help with then. Nothing like wasting time with a wild goose chase.

Symptoms sound like a memory problem. Something autoreleased, probably.

That is the actual code. Just that one line removed. Sorry for that one line, I thought I had removed it there.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Old 08-07-2010, 02:49 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Well, how about posting the entire method.

I'd also be curious about where/how "books" is set up.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 08-07-2010, 06:48 PM   #7 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Just cause you asked.

Here is the rest of the method, actually the code above, as the code previously posted is the bottom of the method

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"BookCell";
    
    BookCellView *cell = (BookCellView *)[self.bookTableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil) {
        cell = [[[BookCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    BookViewStateHolder *stateHolder = appContainerViewController.bookViewStateHolder;
    NSArray *books = [stateHolder getBooksForCurrentMode];
    
    int row = [indexPath row];
    int firstBook = numberOfColumns * row;
And the only line after the code first posted is

Code:
return cell;
}
books is populated from a WebService api call in which the apis are provided by a third party library, and I receive the collection. This apis is used by lots of people out there.

Unfortunately, I cannot be more specific as the app isn't released yet.

Anyway, I updated the way I "reload" the table data that is a bit cleaner and might have solved the issue.

Thanks Brian for all you help again.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 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



» Advertisements
» Online Users: 311
9 members and 302 guests
arash5500, gordo26, HemiMG, linkmx, mediaspree, nobstudio, Objective Zero, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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