parse.com에서 데이터를로드하고 표시하는 UITableview가 있습니다. 그리고 나는 이것이 사용자가 parse.com에서 그것을 삭제 테이블보기에서 항목을 삭제하면 그래서 난 내 자신의 tableview를 사용했다UITableView에서 항목 제거 - Parse.com에서 데이터 가져 오기
편집 할 수 및 사용자 정의 셀 parseSimpleCell.h,하는 .m를 사용하려면
여기내있는 tableview의 .H와하는 .m 파일을 여기에
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "ParseExampleCell.h"
@interface FavoritesTableViewController : UITableViewController <UITableViewDelegate,UITableViewDataSource> {
NSArray *itemsArray;
}
@property (weak, nonatomic) IBOutlet UITableView *favItemsTable;
@end
이
#import "FavoritesTableViewController.h"
@interface FavoritesTableViewController()
@end
@implementation FavoritesTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self performSelector:@selector(retrieveFromParse)];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void) retrieveFromParse {
PFUser *currentUser = [PFUser currentUser];
PFQuery *query = [PFQuery queryWithClassName:@"UserFavourite"];
[query whereKey:@"userIdString" equalTo:currentUser.objectId];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
itemsArray = [[NSArray alloc] initWithArray:objects];
}
[_favItemsTable reloadData];
}];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return itemsArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
ParseExampleCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
PFObject *tempObject = [itemsArray objectAtIndex:indexPath.row];
cell.cellTitle.text = [tempObject objectForKey:@"item"];
cell.tintColor = [UIColor redColor];
return cell;
}
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
}
@end
나는이 방법 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
에서 어떤 일이 일어나는지에 도움이 필요로하는 .m 파일입니다입니다
나는 다른 질문을 보았지만 변수가있는 객체를 보았습니다. 즉, getFromParse 메소드는 commitEditing 스타일 메소드에서 사용할 수 없습니다.
나는이
if (editingStyle == UITableViewCellEditingStyleDelete) {
PFObject *object = [self.objects objectAtIndex:indexPath.row];
[object deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
[self loadObjects];
}];
}
같은 것들을 시도에 불과하다 객체는 당신이 시도한 것은 self.objects
을 의미