Ste*_*eve 0 iphone sdk xcode objective-c
我一直很擅长修复我的Xcode Obj-C错误,但这个让我难过:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[tableList objectAtIndex:indexPath.row] isEqual:@"Standard"]) {
[StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil]];
// ERROR OCCURS HERE:
// error: expected ':' before '*' token
// confused by earlier errors, bailing out
[standard setTitle:@"Standard"];
[self.navigationController pushViewController:standard animated:YES];
[standard release];
}
}
Run Code Online (Sandbox Code Playgroud)
我从YouTube上的视频教程中获取了代码,网址为http://www.youtube.com/watch?v=9ozwoETFei0,然后通过针对Beginning iPhone Development和示例Apple源代码进行检查,修复了编码中的一些错误.我仔细检查以确保错误不在#import页面中.我正在发布上面代码段中发生的编码,以防您认为错误进一步发生:
#import "RootViewController.h"
@implementation RootViewController
@synthesize fetchedResultsController, managedObjectContext;
- (void)viewDidLoad {
self.title = @"Setting Up";
tableList = [[NSMutableArray alloc] init];
[tableList addObject:@"Standard"];
[tableList release];
[super viewDidLoad];
// Set up the edit and add buttons.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
NSError *error;
if (![[self fetchedResultsController] performFetch:&error]) {
// Handle the error...
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release anything that can be recreated in viewDidLoad or on demand.
// e.g. self.myOutlet = nil;
}
#pragma mark Table view methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [tableList count];
}
// 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) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = [[tableList objectAtIndex:indexPath.row] retain];
[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[tableList objectAtIndex:indexPath.row] isEqual:@"Standard"]) {
[StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil]];
// ERROR OCCURS HERE:
// error: expected ':' before '*' token
// confused by earlier errors, bailing out
[standard setTitle:@"Standard"];
[self.navigationController pushViewController:standard animated:YES];
[standard release];
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!史蒂夫(他很"困惑",也想"拯救"!)
Gar*_*ett 10
你没有StandardSetupViewController用括号括起来,这就是问题所在.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[tableList objectAtIndex:indexPath.row] isEqual:@"Standard"]) {
StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil];
[standard setTitle:@"Standard"];
[self.navigationController pushViewController:standard animated:YES];
[standard release];
}
}
Run Code Online (Sandbox Code Playgroud)
你:
[StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil]];
Run Code Online (Sandbox Code Playgroud)
应该:
StandardSetupViewController *standard = [[StandardSetupViewController alloc] initWithNibName:@"StandardSetupViewController" bundle:nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3865 次 |
| 最近记录: |