Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 18, 2010, 08:32 PM   #1
taleryfilms
macrumors newbie
 
Join Date: Aug 2010
error: 'addrowtotableview' undeclared (first use in this function)

Hey guys this is code for a UiTableview in IPHONE SDK xcode. I need to know how to fix these errors. The highlight words are the errors.

here are the error messages:
error: 'addrowtotableview' undeclared (first use in this function)

error: expected ';' before '{' token


Code:
#import "tablearchiveAppDelegate.h"

@implementation tablearchiveAppDelegate

@synthesize window;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    NSArray *archivedarray = [NSKeyedUnarchiver unarchiveObjectWithFile:[self DataFilePath]];
	if (archivedarray == nil) {
		
		data = [[NSMutableArray alloc] init];
		
	}else {
		data = [[NSMutableArray alloc] initWithArray:archivedarray];
	
	
	// Override point for customization after application launch
    [window makeKeyAndVisible];
}

 - (IBAction)addrowtotableview 
{	
		[data addObject:tableCellText.text];
		[self savedata];
		[maintableview reloadData];
	}
	
	- (IBAction)edittable {

		UIBarButton *leftitem;
		[maintableview setEditing:!maintableview.editing animated:YES
		if (maintableview.editing) {
			leftitem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(edittable)];
			
		} else {
			
			leftitem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(edittable)];
	}
		NavItem.rightBarButtonItem = leftitem;
		[self savedata];
		[maintableview reloadData];
	
	- (IBAction)endtext {
	}
	
- (NSInteger)NumberOfSectionsInTableView:(UITableView *)tableview {
	
	return 1;
}
- (NSInteger)tableview:(UITableView *)tableview NumberOfRowsInSection:(NSInteger)section 
{
	
	return [data count];
}
	
- (UITableViewCell *)tableview:(UITableView *)tableview cellRowAtindexPath:(NSIndexPath *)indexpath {

	UITableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:@"Cell"];
	if (cell == nil) {
	
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];
	}

	cell.textLabel.text = [data objectAtIndex:indexpath.row];
	
	return cell; 
}

- (NSString *)datafilepath {
	
	NSString *DataFilePath;
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentdirectory = [paths objectAtIndex: 0];
	DataFilePath = [[documentdirectory stringByAppendingPathComponent:@"applicationdata.plist"] retain];
	return DataFilePath;
	
	- (void)saveData {
		[NSKeyedArchiver archiveRootObject:[data copy] toFile:[self DataFilePath]];
		
		-(void)tableview:(UITab *)tableview commiteditingstlye:(UITableViewCellEditingStyle)editingstyle forrowatindexpath:(NSIndexPath *)indexpath {
			[data removeObjectAtIndex:indexpath.row];
			[tableview deleteRowsAtIndexPaths:[NSArray arraywithobject:indexpath]
							 withRowAnimation:UITableViewRowAnimationLeft];

}	- (void)dealloc;
	[window release];
    [super dealloc];
}


@end
taleryfilms is offline   0 Reply With Quote
Old Aug 18, 2010, 08:43 PM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
error: 'addrowtotableview' undeclared (first use in this function)

Quote:
Originally Posted by taleryfilms View Post
Hey guys this is code for a UiTableview in IPHONE SDK xcode.
Then it should go in the iPhone & iPad Programming Forum.

http://forums.macrumors.com/forumdisplay.php?f=135

I've asked the moderators to move it.


Answer is hilited in BLUE below.
Quote:

error: 'addrowtotableview' undeclared (first use in this function)

error: expected ';' before '{' token


Code:
#import "tablearchiveAppDelegate.h"

@implementation tablearchiveAppDelegate

@synthesize window;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    NSArray *archivedarray = [NSKeyedUnarchiver unarchiveObjectWithFile:[self DataFilePath]];
	if (archivedarray == nil) {
		
		data = [[NSMutableArray alloc] init];
		
	}else {
		data = [[NSMutableArray alloc] initWithArray:archivedarray];
You're missing a } here...
	
	// Override point for customization after application launch
    [window makeKeyAndVisible];
}  
... so this } looks to the compiler like it closes the else block

...and everything below looks like statements, which don't parse.

 - (IBAction)addrowtotableview 
{	
		[data addObject:tableCellText.text];
		[self savedata];
		[maintableview reloadData];
	}
	
	- (IBAction)edittable {

		UIBarButton *leftitem;
		[maintableview setEditing:!maintableview.editing animated:YES
		if (maintableview.editing) {
			leftitem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(edittable)];
			
		} else {
			
			leftitem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(edittable)];
	}
		NavItem.rightBarButtonItem = leftitem;
		[self savedata];
		[maintableview reloadData];
	
	- (IBAction)endtext {
	}
	
- (NSInteger)NumberOfSectionsInTableView:(UITableView *)tableview {
	
	return 1;
}
- (NSInteger)tableview:(UITableView *)tableview NumberOfRowsInSection:(NSInteger)section 
{
	
	return [data count];
}
	
- (UITableViewCell *)tableview:(UITableView *)tableview cellRowAtindexPath:(NSIndexPath *)indexpath {

	UITableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:@"Cell"];
	if (cell == nil) {
	
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];
	}

	cell.textLabel.text = [data objectAtIndex:indexpath.row];
	
	return cell; 
}

- (NSString *)datafilepath {
	
	NSString *DataFilePath;
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentdirectory = [paths objectAtIndex: 0];
	DataFilePath = [[documentdirectory stringByAppendingPathComponent:@"applicationdata.plist"] retain];
	return DataFilePath;
	
	- (void)saveData {
		[NSKeyedArchiver archiveRootObject:[data copy] toFile:[self DataFilePath]];
		
		-(void)tableview:(UITab *)tableview commiteditingstlye:(UITableViewCellEditingStyle)editingstyle forrowatindexpath:(NSIndexPath *)indexpath {
			[data removeObjectAtIndex:indexpath.row];
			[tableview deleteRowsAtIndexPaths:[NSArray arraywithobject:indexpath]
							 withRowAnimation:UITableViewRowAnimationLeft];

}	- (void)dealloc;
	[window release];
    [super dealloc];
}


@end

Last edited by chown33; Aug 18, 2010 at 09:13 PM.
chown33 is offline   0 Reply With Quote
Old Aug 18, 2010, 08:45 PM   #3
taleryfilms
Thread Starter
macrumors newbie
 
Join Date: Aug 2010
k

Quote:
Originally Posted by chown33 View Post
Then it should go in the iPhone & iPad Programming Forum.

http://forums.macrumors.com/forumdisplay.php?f=135

I've asked the moderators to move it.
k thanks
taleryfilms is offline   0 Reply With Quote
Old Aug 18, 2010, 09:12 PM   #4
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
Hey man. You might want to start at the beginning. Are you following a book or online course?

Your braces aren't balanced. They teach that on day one of iPhone coding school.

Ew, and you cross-posted. And you probably registered today to ask this question.

This is not how you learn to program.
PhoneyDeveloper is offline   0 Reply With Quote
Old Aug 18, 2010, 09:35 PM   #5
taleryfilms
Thread Starter
macrumors newbie
 
Join Date: Aug 2010
Quote:
Originally Posted by PhoneyDeveloper View Post
Hey man. You might want to start at the beginning. Are you following a book or online course?

Your braces aren't balanced. They teach that on day one of iPhone coding school.

Ew, and you cross-posted. And you probably registered today to ask this question.

This is not how you learn to program.
Im following an online tutorial on youtube. http://www.youtube.com/watch?v=tMo8T...eature=channel
taleryfilms is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
What mic is used in this vid (wireless radio mic) steveOooo Digital Video 13 Sep 16, 2010 08:54 AM
error: request for member 'myLabel' in something not a structure or union PreethaAjayan iPhone/iPad Programming 0 Jun 23, 2009 12:03 AM
*object* undeclared (first use in function) problem RPGamerL99 iPhone/iPad Programming 6 Oct 2, 2008 07:36 PM
Recreating Apple's HW Code Error "undeclared (first use in this function)" Hot Sauce79 iPhone/iPad Programming 10 Jul 1, 2008 12:32 PM
Can someone help me with this? (buy in US, use in UK) richbrown iPhone 8 Jan 17, 2007 01:23 PM


All times are GMT -5. The time now is 10:32 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC