导致此Objective-C编译错误的原因:程序中的Stray'\ 235'

时间:2010-11-15 19:34:20

标签: iphone objective-c

#import "InstatwitViewController.h"

@implementation InstatwitViewController


- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *) pickerView {
 return 2;
}

- (NSInteger)pickerView:(UIPickerView *) pickerViewnumberOfRowsInComponent :(NSInteger)component {

if (component == 0)
 return [activities count];
else
 return [feelings count]; 
}

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
 activities = [[NSArray alloc] initWithObjects:@”sleeping”, @”eating”, @”working”, @”thinking”, @”crying”, 
    @”begging”, @”leaving”, @”shopping”, @”hello worlding”, nil];
 feelings = [[NSArray alloc] initWithObjects:@”awesome”, @”sad”, @”happy”, @”ambivalent”, 
    @”nauseous”, @”psyched”, @”confused”, @”hopeful”, @”anxious”, nil];
}



/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (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.
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {

 switch (component) { 
  case 0:
   return [activities objectAtIndex:row]; 
  case 1:
   return [feelings objectAtIndex:row];
 }
 return nil;
}

- (void)viewDidUnload {
 // Release any retained subviews of the main view.
 // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [activities release]; 
 [feelings release]; 
 [super dealloc];
}

@end

我得到以下错误

  

程序中迷路'\ 235'     - 还有100多个不同的数字   缺少哨兵函数调用   InstatwitViewController类的不完整实现

任何帮助,只是从书中做一个教程,完全复制,并且看不到什么错误

2 个答案:

答案 0 :(得分:8)

您的代码包含智能引号。他们需要直接引用。

这样的行:

activities = [[NSArray alloc] initWithObjects:@”sleeping”, @”eating”, @”working”, @”thinking”, @”crying”, 
    @”begging”, @”leaving”, @”shopping”, @”hello worlding”, nil];

需要:

activities = [[NSArray alloc] initWithObjects:@"sleeping", @"eating", @"working", @"thinking", @"crying", 
    @"begging", @"leaving", @"shopping", @"hello worlding", nil];

答案 1 :(得分:0)

错误可能是由copied exactly引起的。这意味着您的代码中至少有一个编译器无法解析的字符。