Hi
Difficult to say, but a few thing to help debug:
1- instead of always calling
Code:
[[rateData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row]
in various places, you should store it in a local variable and use that instead. It will make your code easier to read
2- and on top of that it will be slightly faster Since the runtime will not be calling over and over the same piece of code, so I will suggest that you add at the beginning:
Code:
NSDictionnary *record = [[rateData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row];
And then simply use record objectForKey:...
Now for your problem I will either put a breakpoint when you try to create the image or rather write the code as:
Code:
NSString *imageName = [record objectForKey:@"picture"];
NSLog(@"image is: %@", imageName);
Then do the code for UIImage imageNamed:...
Check the app logs and see what the logis showing for the image name... Is the name correct ? is the image referred in the log in your project? ==> imageNamed will only find image in your project.
Finally you should try to put some breakpoint with XCode to see where the crash happen.
Quote:
Originally Posted by crosspjc
Hi all,
A noob here (be nice) who has looked everywhere to sort my problem out.
I have a UITableView navigation controller which contains a mutable array of mutable dictionaries. I am trying to pass a picture included in one of the dictionaries to another view.
The app runs but when I try to select the row it crashes with no error messages  . It seems to pass web addresses to a webview but not .png images to an image view. Any help would be really appreciated as I have been trying to solve the issue for three weeks!
Relevant code as follows:
Code:
//RootViewController.m
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *title1 = [[[rateData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"name"];
........
else if ([title1 isEqualToString:@"Corporation Tax"])
{
TaxRatesViewController *taxRatesViewController =
[[TaxRatesViewController alloc] initWithNibName:
@"TaxRatesViewController" bundle:nil];
[[taxRatesViewController taxRatesView] setImage:[UIImage imageNamed:[[[rateData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"picture"] ]];
/* taxRatesViewController.rates = [[UIImage alloc] imageNamed:[[[rateData objectAtIndex:indexPath.section] objectAtIndex: indexPath.row] objectForKey:@"picture"] ];*/
taxRatesViewController.title=
[[[rateData objectAtIndex:indexPath.section] objectAtIndex:
indexPath.row] objectForKey:@"name"];
[self.navigationController pushViewController:
taxRatesViewController animated:YES];
[taxRatesViewController release];
}
//dictionary element contained in RootViewController.m
[t2010_11 addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Corporation Tax",@"name",@"haslers.png",@"picture",@"HTTP://www.twitter.com",@"URL",@"2010PERSONAL.PNG",@"ratesPNG", nil]];
// taxRatesViewController
- (void)viewDidLoad
{
[taxRatesView setImage:rates];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
In theory this is probably something really easy but I just can't get my head around it. Any ideas? I don't mind doing my own research but I have run out of places to look!
Thanks
|