0

试图简单地清除目标 C 中另一个类中的可变数组的问题,代码运行良好,只是数据没有被擦除....

SecondViewController.h

@interface SecondViewController : UIViewController <UITableViewDelegate,UITextFieldDelegate,ABPeoplePickerNavigationControllerDelegate>
{
    AppDelegate *appDelegate;
}
@property (nonatomic, retain) NSMutableArray *contactsArray;

这就是可变数组的声明......

然后从我试图删除它的类中。

列表视图控制器.h

#import "SecondViewController.h"

@interface ListViewController : UIViewController <UITableViewDelegate,ABPeoplePickerNavigationControllerDelegate,UITabBarControllerDelegate>{
    AppDelegate *appDelegate;
    SecondViewController *secondViewControl;
}
@property (nonatomic, retain) IBOutlet UITableView *table;

然后在主文件中我使用代码

[secondViewControl.contactsArray removeAllObjects];

但是当我检查数组时它没有被清空......

编辑:

@implementation ListViewController
@synthesize table;
/*- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}*/

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
    secondViewControl = [[SecondViewController alloc]init];
4

0 回答 0