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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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-13-2009, 06:14 PM   #1 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
Default Table View Cell Problem/ Question

Hey everyone,
I'm working on an app that has a table view in it. I had no problem using it and navigation was working great but I decided that it would look more professional if I had the Name and than a mini summary of the next view when you tapped on the cell. I designed my custom cell but the problem I am having is loading up a new view when a particular cell is tapped. I used isEqual to the name of one of the arrays when I used a regular table view but now I get an error saying too many arguments to function 'isEqual'

Here is what my code looks like
Code:
NSString *customCellContent[][2]  = {
{@"Sample", @"blah blah"},
{@"Sample 2", @"blah blah"},
// and it keeps going
};

@implementation Sample
@synthesize tableContent, theCustomCell;

-(void) loadTestData {
	// fill moviesArray with test data
	for (int i=0; i< 10; i++) {
		CustomCell *theCell = [[CustomCell alloc] init];
		theCell.title = customCellContent[i][0];
		theCell.summary = customCellContent[i][2];
		[tableContent addObject: theCell];
		[theCell release];
	}
}

- (void)viewDidLoad {
	[super viewDidLoad];
	self.title = @"Sample";
	tableContent = [[NSMutableArray alloc] init];
	
	[self loadTestData];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
	static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (cell == nil) {
		[[NSBundle mainBundle] loadNibNamed:@"CustomCell" 
									  owner:self options:NULL]; 
		cell = theCustomCell; 
    }
    
    // Set up the cell...
	CustomCell *aCell = [tableContent objectAtIndex:indexPath.row];
	UILabel *titleLabel = (UILabel*) [cell viewWithTag:1];
	titleLabel.text = aCell.title;
	UILabel *summaryLabel = (UILabel*) [cell viewWithTag:3];
	summaryLabel.text =  aCell.summary;
	return cell;
	
}

//here is my problem
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	
	if ([[tableContent objectAtIndex:indexPath.row] isEqual:@"Sample", @"blah blah"])
	{
		SampleViewController *sample = [[SampleViewController alloc] initWithNibName:@"SampleViewController" bundle:nil];
		[sample setTitle:@"Sections"];
		ApptitutorAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
		[delegate.sampleNavController pushViewController:sample animated:YES];
		
	}
}
Any help would be greatly appreciated!
Thanks!
iPhonig
iphonig is offline   Reply With Quote
Old 10-13-2009, 06:32 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 52
Default

if ([[tableContent objectAtIndex:indexPath.row] isEqual:@"Sample", @"blah blah"])

This is not the objective C way to send a message that takes two arguments. Did you define an IsEqual message in your CustomCell class? If so, then I would expect call to look like

[[tableContent objectAtIndex:indexPath.row] isEqual: @"Sample" secondArg: @"blah blah"];

Where secondArg would be replaced by whatever you called it.
Iphoneer is offline   Reply With Quote
Old 10-13-2009, 06:54 PM   #3 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
Default

Quote:
Originally Posted by Iphoneer View Post
if ([[tableContent objectAtIndex:indexPath.row] isEqual:@"Sample", @"blah blah"])

This is not the objective C way to send a message that takes two arguments. Did you define an IsEqual message in your CustomCell class? If so, then I would expect call to look like

[[tableContent objectAtIndex:indexPath.row] isEqual: @"Sample" secondArg: @"blah blah"];

Where secondArg would be replaced by whatever you called it.
No I didn't how do I do that?
iphonig is offline   Reply With Quote
Old 10-13-2009, 09:43 PM   #4 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 52
Default

Quote:
Originally Posted by iphonig View Post
No I didn't how do I do that?
You don't need it for something like this. Just make two comparisons.

if ([[[tableContent objectAtIndex:indexPath.row] title ] isEqual:@"Sample"] && [[[tableContent objectAtIndex:indexPath.row] summary ] isEqual:@"blah blah"])
Iphoneer is offline   Reply With Quote
Old 10-14-2009, 12:35 AM   #5 (permalink)
Reena
 
Join Date: Apr 2009
Posts: 31
Default

Quote:
Originally Posted by iphonig View Post
Hey everyone,
I'm working on an app that has a table view in it. I had no problem using it and navigation was working great but I decided that it would look more professional if I had the Name and than a mini summary of the next view when you tapped on the cell. I designed my custom cell but the problem I am having is loading up a new view when a particular cell is tapped. I used isEqual to the name of one of the arrays when I used a regular table view but now I get an error saying too many arguments to function 'isEqual'

Here is what my code looks like
Code:
NSString *customCellContent[][2]  = {
{@"Sample", @"blah blah"},
{@"Sample 2", @"blah blah"},
// and it keeps going
};

@implementation Sample
@synthesize tableContent, theCustomCell;

-(void) loadTestData {
	// fill moviesArray with test data
	for (int i=0; i< 10; i++) {
		CustomCell *theCell = [[CustomCell alloc] init];
		theCell.title = customCellContent[i][0];
		theCell.summary = customCellContent[i][2];
		[tableContent addObject: theCell];
		[theCell release];
	}
}

- (void)viewDidLoad {
	[super viewDidLoad];
	self.title = @"Sample";
	tableContent = [[NSMutableArray alloc] init];
	
	[self loadTestData];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
	static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (cell == nil) {
		[[NSBundle mainBundle] loadNibNamed:@"CustomCell" 
									  owner:self options:NULL]; 
		cell = theCustomCell; 
    }
    
    // Set up the cell...
	CustomCell *aCell = [tableContent objectAtIndex:indexPath.row];
	UILabel *titleLabel = (UILabel*) [cell viewWithTag:1];
	titleLabel.text = aCell.title;
	UILabel *summaryLabel = (UILabel*) [cell viewWithTag:3];
	summaryLabel.text =  aCell.summary;
	return cell;
	
}

//here is my problem
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	
	if ([[tableContent objectAtIndex:indexPath.row] isEqual:@"Sample", @"blah blah"])
	{
		SampleViewController *sample = [[SampleViewController alloc] initWithNibName:@"SampleViewController" bundle:nil];
		[sample setTitle:@"Sections"];
		ApptitutorAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
		[delegate.sampleNavController pushViewController:sample animated:YES];
		
	}
}
Any help would be greatly appreciated!
Thanks!
iPhonig


try this

if ([[tableContent objectAtIndex:indexPath.row] isEqual:@"Sample"] || [[tableContent objectAtIndex:indexPath.row] isEqual:@"blah blah"])
reena is offline   Reply With Quote
Reply

Bookmarks

Tags
cell, custom, navigation, table, view

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
» Stats
Members: 158,885
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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