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 10-12-2011, 10:31 PM   #26 (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

No, it is printing null, it is returning nil. So your test will be:

Code:
if ([dictionary objectForKey:theKey] == nil)
__________________
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 10-13-2011, 12:06 PM   #27 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 63
CanDev is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
No, it is printing null, it is returning nil. So your test will be:

Code:
if ([dictionary objectForKey:theKey] == nil)
That was what I was missing, I was under the assumption that when looking for a key in a plist, if it returned nil then nothing would be done and if it returned a value, then it would act upon that.

I have now added the if statement to do just that. I never did understand getting information from plists very much but now I know a little more and will pass on what I know.

Thank you everyone for your help...here is what I ended up with
Code:
        //adding image to cell
    
    if ([dictionary objectForKey:@"imageKey"] == nil) {
        return cell;
    } else {
        NSString *path = [[NSBundle mainBundle] pathForResource:[dictionary objectForKey:@"imageKey"] ofType:@"png"];
        UIImage *theImage = [UIImage imageWithContentsOfFile:path];
        cell.imageView.image = theImage;
    }

Last edited by CanDev; 10-13-2011 at 12:08 PM.
CanDev is offline   Reply With Quote
Old 10-13-2011, 12:14 PM   #28 (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

With a long enough list, that still won't work. You need to clear out the image view.
__________________
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 10-13-2011, 12:26 PM   #29 (permalink)
Registered Member
 
Join Date: Oct 2011
Location: NYC
Posts: 29
objch is on a distinguished road
Default

You want to return a cell in all cases, so leave return cell at the end of the method.

This cell could be brand new or dequeued (re-used), so your if statement should also be dealing with cases where an existing image needs to be removed.

It's also not clear to me how [dictionary objectForKey:@"imageKey"] isn't returning the same value for every cell, unless the value of dictionary is changing each time?
objch is offline   Reply With Quote
Old 10-13-2011, 12:27 PM   #30 (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

Quote:
Originally Posted by objch View Post
It's also not clear to me how [dictionary objectForKey:@"imageKey"] isn't returning the same value for every cell, unless the value of dictionary is changing each time?
Post #18. OP was truncated.
__________________
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 10-13-2011, 12:35 PM   #31 (permalink)
Registered Member
 
Join Date: Oct 2011
Location: NYC
Posts: 29
objch is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Post #18. OP was truncated.
Ah right, thanks. Guess that's what I get for skipping to the end!
objch is offline   Reply With Quote
Old 10-13-2011, 11:52 PM   #32 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 63
CanDev is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
With a long enough list, that still won't work. You need to clear out the image view.
Also, I get everything working as intended. Those cells that would have an image according to the imageKey show the proper image, and those that dont show nothing. Even for parts of my table that are over 75 items long. Now I am not saying that is a long list, because this is the first time that I have gotten things to work the way I want them to. So do I really need to clear the image?

Also, I have run it through instruments and I am not getting any memory leaks, as far as I can tell.

Your thoughts?
CanDev is offline   Reply With Quote
Old 10-14-2011, 06:04 AM   #33 (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

It's not a matter of leaks, it's a matter of cell recycling. You aren't (or shouldn't be) dealing with a brand new cell every time. The cell you have could be a cell that already has an image from a previous row. You look for the key, and if it isn't there just return the cell. So the old image should be there. It's dumb luck if you arent seeing that happen already, or you don't have very many non-image rows.
__________________
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
Reply

Bookmarks

Tags
cell.image, imageview, tableview, tableview cell

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: 402
16 members and 386 guests
13dario13, 7twenty7, buggen, eski, EvilElf, glenn_sayers, LunarMoon, morterbaher, n00b, pbart, QuantumDoja, sacha1996, Sami Gh, UMAD, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,906
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

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