开发者

what's wrong in this Nsarray definition

开发者 https://www.devze.com 2023-03-09 16:22 出处:网络
I want to initialize an array of nsstrings I use the following code @interface Modalities : UITableViewController {

I want to initialize an array of nsstrings I use the following code

@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];
}

it raise

error: expected unqualified-id before '=' token

any suggestion to solve that


You used the name of the Class for your field, this will cause a collision.

Change names of the field to

NSArray * modalities;

and then:

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

精彩评论

暂无评论...
验证码 换一张
取 消