Objective C不同类中的空数组

时间:2013-06-15 12:06:17

标签: objective-c arrays

试图在目标C中简单地清除另一个类中的mutablearray 代码都运行良好,只是数据不会被擦除....

SecondViewController.h

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

这是可变阵列的宣言......

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

listViewController.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];

0 个答案:

没有答案