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 Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 07-28-2011, 07:32 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 2
crosspjc is on a distinguished road
Default UITableView Driving me Crazy!

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
crosspjc is offline   Reply With Quote
Old 07-29-2011, 01:00 AM   #2 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 32
iosdevjtp is on a distinguished road
Default

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 View Post
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
iosdevjtp is offline   Reply With Quote
Old 08-04-2011, 03:10 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 2
crosspjc is on a distinguished road
Default

Thank you for your help on this. The log shows the correct image and details the following error:

Quote:
2011-08-04 09:03:33.754 TaxTables[286:207] image is : 2010PERSONAL.png
2011-08-04 09:03:33.758 TaxTables[286:207] -[UIImageView scale]: unrecognized selector sent to instance 0x4e09050
2011-08-04 09:03:33.763 TaxTables[286:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView scale]: unrecognized selector sent to instance 0x4e09050'
I have searched google on this and some are saying that it is to do with memory management i.e. I am releasing the object early. I have looked through my code again and don't think this is the case . Has anyone had experience with this error.

Again I don't expect anyone to correct the code just to point me in the right direction.

Thanks
crosspjc is offline   Reply With Quote
Old 08-04-2011, 04:38 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 54
tomneo2004 is on a distinguished road
Default

Quote:
Originally Posted by crosspjc View Post
Thank you for your help on this. The log shows the correct image and details the following error:



I have searched google on this and some are saying that it is to do with memory management i.e. I am releasing the object early. I have looked through my code again and don't think this is the case . Has anyone had experience with this error.

Again I don't expect anyone to correct the code just to point me in the right direction.

Thanks
log say scale this message send to UIImageView object which does not have scale this method. Maybe you should looking for the code that call scale on UIImageView object.
tomneo2004 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: 406
11 members and 395 guests
AppleDev, chemistry, Gi-lo, ipodphone, mistergreen2011, pipposanta, QuantumDoja, Retouchable, RobTaku, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,925
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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