Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Also, the way you have it right now, every cell is getting the same image every time.
If you want to have different images in different cells, you need to make use of the indexPath argument of tableView:cellForRowAtIndexPath: and relate that to the contents of your property list.
Are you a programmer or not? Make some decisions. Use some programming logic. When do you want an image? When do you NOT want an image?
isnt that the whole point of the list. To place images where you indicate a key and the parts of the list that dont have an associated key with that value should get the image.
But we've already established that you get a path every time, so your logic is flawed.
exactly, and i dont know how to fix that. Thats why i ask the people who know these things. It would seem logical to me that when the program looks through the plist, it would only place an image in the table where the key would indicate and if there were no key in that dictionary then no image would be available to be shown. So I dont know where its getting the path from when that key doesnt exist.
You keep missing my point. Which part of the code - given that we have proven you get a path every time - leads you to believe that you would ever NOT get an image? What are you doing to prevent there from being an image shown?
You keep missing my point. Which part of the code - given that we have proven you get a path every time - leads you to believe that you would ever NOT get an image? What are you doing to prevent there from being an image shown?
not limit the responses and only return a path for those items with the key "imageKey". What I dont understand and obviously what I am missing is, why do I get a path returned everytime even though there is no key with that name.
My top layer of my table has an image for each table entry, then as I drill down, some of the sub catagories do not have images assigned (ie. No key, or no value for the key "imageKey"
As objch suggested, why would the value for "dictionary" ever be different?
because its the value of "imageKey" that is different (or not there at all). Where I do have values for it, I get different images for each cell as expected.
No no, the dictionary itself. Why would the dictionary ever be different? Is there some code that you aren't showing here? Because if that is the complete cellForRow above, then dictionary will be the same for every single row.
No no, the dictionary itself. Why would the dictionary ever be different? Is there some code that you aren't showing here? Because if that is the complete cellForRow above, then dictionary will be the same for every single row.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //Get the dictionary of the selected data source. NSDictionary *dictionary = [self.competingBands objectAtIndex:indexPath.row];
//Get the children of the present item. NSArray *Children = [dictionary objectForKey:@\"Children\"];
//Increment the Current View BLVController.CurrentLevel += 1; NSLog(@\"Implement current View\"); //Set the title; BLVController.CurrentTitle = [dictionary objectForKey:@\"Title\"];
//Push the new table view on the stack [self.navigationController pushViewController:BLVController animated:YES]; NSLog(@\"New view pushed onto stack\"); BLVController.competingBands = Children;
I'm not very experienced, so take my advice with a grain or two of salt.
I think the issue may have something to do with the lack of imageKey on some of the dictionaries. If its returning "null" ofType "png", is it assigning the first available png file from your resources? Do you have an image set manually in IB, such that when it gets null, it just has the one initially assigned?
Just throwing stuff out there to ponder. I have a new found hatred for images on cells from my own app experience these last 2 days.
Ah yes, when posting code, it's always useful to neglect to point out that not everything is included. That makes troubleshooting so much easier.
So in the rows that are not supposed to have images, what images do they wind up getting? Are they the same every time, or different?
And the bottom line is this: you're expecting the path to be nil in that case. That isn't happening, so you need to try something else. You've already stated two or three times what the criteria is, so I really don't understand why you're having so much trouble thinking of something to try.
Ah yes, when posting code, it's always useful to neglect to point out that not everything is included. That makes troubleshooting so much easier.
So in the rows that are not supposed to have images, what images do they wind up getting? Are they the same every time, or different?
And the bottom line is this: you're expecting the path to be nil in that case. That isn't happening, so you need to try something else. You've already stated two or three times what the criteria is, so I really don't understand why you're having so much trouble thinking of something to try.
The rows that are not supposed to have images, have the first image alphabetically that i have in my images folder. So is there a way to have a key return nil instead of null. Obviously on a null return, it defaults to my first image, which I dont want.
My images are all set programatically, not thru IB
You're not thinking this through at all. The problem is not with the key, the problem is with the path sniffer. objectForKey already does return nil if the key isn't there. SO TEST FOR THE PRESENCE OF THE KEY. Jesus. If you want A to happen in one situation, but B to happen in another, write a freaking test. if A else B. This is Programming Logic 101 here.
You're not thinking this through at all. The problem is not with the key, the problem is with the path sniffer. objectForKey already does return nil if the key isn't there. SO TEST FOR THE PRESENCE OF THE KEY. Jesus. If you want A to happen in one situation, but B to happen in another, write a freaking test. if A else B. This is Programming Logic 101 here.
Well first off, I never once said i was a programmer. This is all new to me and I am trying to do the best I can, and thats why i am asking questions on this forum. I didnt know this forum was for the experienced programmers. Anyway, if the key isnt there, its returning null, according to the NSLog, but I guess i dont know enough about that to be sure. So I will figure out an if statement to work if there is no key for my object for that particular part of my table.
Sorry to waste your time Brian, good day to you :) Off to read more of the documentation that isnt always as clear as I would like.
And While i am at it, I did read your series on tablesview, very good! very informative, waiting for the rest :)
Replies
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeIf you want to have different images in different cells, you need to make use of the indexPath argument of tableView:cellForRowAtIndexPath: and relate that to the contents of your property list.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeYes I do get a path when logged and an image for each cell, but the key returns (null) for those that dont have a key ... which is correct.
So I want to have an image show up for only those cells that I assign a value to the key
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeMy top layer of my table has an image for each table entry, then as I drill down, some of the sub catagories do not have images assigned (ie. No key, or no value for the key "imageKey"
example snippet of my plist
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeThis is my cellForRowAtIndexPath
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeThis is assuming your .png file has the same name as your value for Key. ie : imageKey = Russia, and the png is Russia.png (not RussiaImage.png).
Hope this helps/provides some insight.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeI think the issue may have something to do with the lack of imageKey on some of the dictionaries. If its returning "null" ofType "png", is it assigning the first available png file from your resources? Do you have an image set manually in IB, such that when it gets null, it just has the one initially assigned?
Just throwing stuff out there to ponder. I have a new found hatred for images on cells from my own app experience these last 2 days.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSo in the rows that are not supposed to have images, what images do they wind up getting? Are they the same every time, or different?
And the bottom line is this: you're expecting the path to be nil in that case. That isn't happening, so you need to try something else. You've already stated two or three times what the criteria is, so I really don't understand why you're having so much trouble thinking of something to try.
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeMy images are all set programatically, not thru IB
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSorry to waste your time Brian, good day to you :) Off to read more of the documentation that isnt always as clear as I would like.
And While i am at it, I did read your series on tablesview, very good! very informative, waiting for the rest :)
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome