私は1つのtabbarcontrollerにLoginとComplete Tabを持っています。LoginTab の Logout ボタンをクリックしたいのですが、COMplete タブのすべてのデータとテーブルビューがリセットされます。このコードを使用しましたが、機能しません:
CompleteTab.m では:
-(void) viewDidLoad
{
temp = [[NSMutableArray alloc] init];
iduploadArray= [[NSMutableArray alloc] init];
FileCompletedArray = [[NSMutableArray alloc] init];
DiffArr= [[NSMutableArray alloc] init];
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
tableData = [[NSArray alloc] initWithObjects:FileCompletedArray,nil];
// [_tableView setAllowsSelection:YES];
//tableView.dataSource = self;
// [self.view addSubview:tableView];
// [self parseXMLFile:@"x"];
NSURL *url1 = [NSURL URLWithString:@"server.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL: url1] ;
....
temp = [FileCompletedArray mutableCopy];
_tableView.dataSource = self;
_tableView.delegate=self;
[self.view addSubview:_tableView];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", error);//: %@", operation.responseString);
}
];
[httpClient enqueueHTTPRequestOperation:operation];
}
-(void) resetAll
{
[temp removeAllObjects];
[FileCompletedArray removeAllObjects];
[DiffArr removeAllObjects];
[_tableView reloadData];
}
LoginTab.m で:
- (IBAction)LogoutButton:(id)sender {
login = false;
username.hidden = NO;
pass.hidden = NO;
LoginButton.hidden = NO;
LogoutButton.hidden = YES;
//make all the arrays get reset
username.text =@"";
pass.text = @"";
[completeview resetAll];
}
デバッグ: [ログアウト] ボタンをクリックすると、resetAll() 関数が呼び出されますが、各変数は 0x000000 です。したがって、データをリセットしてテーブルビューをリロードすることはできません。手伝って頂けますか?ありがとう