tableViewからセルを削除するのに多くの問題がありました。スワイプすると表示されるスライドセルに3つのボタンがあり、スワイプを呼び出すメソッドはJBSliderViewControllerにあります。homeViewController に埋め込まれたクラス メソッドにアクセスするために、JBSliderViewController 内にインスタンス メソッドを作成して、homeViewController 内にある-(void)callDeleteFound
+(void)deleteFound を呼び出します。
私の問題は、tableViewにアクセスして呼び出すことができず、– deleteRowsAtIndexPaths:withRowAnimation:
nullcurrentTable
を返すことです
助言がありますか?
JBSliderController 内
- (void)callDeletefound {
[homeViewController deleteFound];
}
homeViewController内
+ (void)deleteFound {
NSUserDefaults *userSessionData = [NSUserDefaults standardUserDefaults];
NSString *userID = [userSessionData stringForKey:@"userID"];
NSString *authKey = [userSessionData stringForKey:@"authKey"];
NSString *appVersion = [userSessionData stringForKey:@"appVersion"];
NSString *versionedURL = [NSString stringWithFormat:@"/ios/%@/", appVersion];
NSURL *url = [NSURL URLWithString:@"http://website.com"];
NSString *postPath = [NSString stringWithFormat:@"%@deletefind.php", versionedURL];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
userID, @"userid",
[MyClass friendID], @"friendid",
authKey, @"tempAuth",
nil];
[httpClient postPath:postPath parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
[SVProgressHUD showSuccessWithStatus:@"Removed from notifications"];
NSMutableArray *notificationArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"notificationsArray"];
NSMutableArray *arrayThatYouCanRemoveObjects = [NSMutableArray arrayWithArray:notificationArray];
NSLog(@"%@", [MyClass cellNum]);
NSInteger *num = [[MyClass cellNum] integerValue];
[arrayThatYouCanRemoveObjects removeObjectAtIndex:num];
[currentTable deleteRowsAtIndexPaths:openedCellIndexPath withRowAnimation:UITableViewRowAnimationLeft];
[currentTable reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"[HTTPClient Error]: %@", error.localizedDescription);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Fail" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}];
}