这个Nsarray定义有什么不对

时间:2011-05-31 07:27:10

标签: iphone objective-c ios ipad nsarray

我想初始化一个nsstrings数组我使用下面的代码

@interface Modalities : UITableViewController {

    NSArray * Modalities ;

    NSArray* SelectedOnes ;
}

@property (nonatomic, retain) NSArray * Modalities ;

@end

- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

    Modalities = [NSArray arrayWithObjects:
                  @"XA",
                  @"CT",
                  @"RF",
                  @"PR",
                  @"US",
                  @"OT",
                  @"SR",
                  @"MG",
                  @"MR",
                  @"NM",              
                  @"CR" , nil];
}

它提升

  

错误:预期的nonqualified-id之前   '='标记

任何解决该问题的建议

1 个答案:

答案 0 :(得分:2)

您为字段使用了Class的名称,这将导致冲突。

将字段名称更改为

NSArray * modalities;

然后:

modalities = [NSArray arrayWithObjects:
              @"XA",
              @"CT",
              @"RF",
              @"PR",
              @"US",
              @"OT",
              @"SR",
              @"MG",
              @"MR",
              @"NM",              
              @"CR" , nil];