Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在OSX应用程序的NSTableview中显示数组值_Objective C_Cocoa_Nstableview - Fatal编程技术网

Objective c 如何在OSX应用程序的NSTableview中显示数组值

Objective c 如何在OSX应用程序的NSTableview中显示数组值,objective-c,cocoa,nstableview,Objective C,Cocoa,Nstableview,我的viewController.xib有一个按钮和tableview,我有一些数组值。如果我单击button,数组数据将显示在tableview中。 是否可以不使用ApplicationIDFinishLaunching方法。谢谢。我在问OSX应用程序的这个问题。您可以按照本教程进行操作:如何连接或将NSTableView控制器连接到myviewController.xib的设置。请回复我按照本教程获取帮助 - (NSInteger)numberOfSectionsInTableView:(U

我的viewController.xib有一个按钮和tableview,我有一些数组值。如果我单击button,数组数据将显示在tableview中。
是否可以不使用ApplicationIDFinishLaunching方法。

谢谢。我在问OSX应用程序的这个问题。您可以按照本教程进行操作:如何连接或将NSTableView控制器连接到myviewController.xib的设置。请回复我按照本教程获取帮助
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return exampleArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [exampleTableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) 
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellWithSwitch"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.font = [UIFont systemFontOfSize:14];
    }
    cell.textLabel.text = [exampleArray objectAtIndex:indexPath.row];
}

-(IBAction)exampleButtonAction:(id)sender
{
     exampleArray=[[NSMutableArray alloc]initWithObjects:@"example1",@"example2",@"example3",@"example4",nil];
     [exampleTableView reloadData];
}