'findObjectsInBackgroundWithBlock'을 사용하여 데이터를 가져 와서 개체를 만드는 Parse 프로그램을 실행하고 있습니다. 완료되면 자동으로 '[self.tableView setNeedsDisplay]'를 호출하지만 내 디스플레이에는 아무런 변화가 없으며 새로운 항목이 표시되지 않습니다. 내가 뭔가 잘못하고 있는거야? 어떻게 수정해야합니까?IOS FindObjectsInBackgroundWithBlock -> setNeedsDisplay
-(void)pullDown{
NSLog(@"Began PullDown");
NSMutableArray *bugs = [NSMutableArray arrayWithObjects: nil];
//NSMutableArray *bugs = [NSMutableArray arrayWithObjects: nil];
NSLog(@"Journal POSTS");
PFQuery *queryJournal = [PFQuery queryWithClassName:@"Post"];
[queryJournal whereKey:@"user" equalTo:[PFUser currentUser]];
NSLog(@"WHEN ARE YOU CALLED?");
[queryJournal findObjectsInBackgroundWithBlock:^(NSArray *posts, NSError *error) {
if (!error) {
// The find succeeded.
//NSLog(@"Successfully retrieved %@ Posts.", posts);
// Do something with the found objects
for (PFObject *object in posts) {
int rating = object[@"Rating"];
NSLog(@"RATING object: %@; int: %i", object[@"Rating"], rating);
MSJournalerDoc *post = [[MSJournalerDoc alloc] initWithTitle:object[@"Title"] rating:rating thumbImage:object[@"imageFile"] fullImage:object[@"imageFile"]];
[bugs addObject:post];
}
NSLog(@"HELL YA");
NSLog(@"THE LIST: %@", bugs);
self.bugs = bugs;
NSLog(@"END OF LOOOOOOOOOOOOOOOPS %lu", bugs.count);
[self.tableView setNeedsDisplay];
NSLog(@"MOAR");
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if ([PFUser currentUser]) {
NSLog(@"CURRENT USER");
[self pullDown];
NSLog(@"POST CURRENT USER");
}
else{
[self createUser];
[self createBug];
}
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
self.navigationItem.rightBarButtonItem = addButton;
//Change the Title
self.title = @"Posts";
self.navigationItem.leftBarButtonItem = self.editButtonItem;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self action:@selector(addTapped:)];
NSLog(@"Finished ViewDidLoad");
}
새 데이터로 테이블보기를 다시로드하려면 setNeedsDisplay가 아닌 reloadData를 사용해야합니다. – rdelmar
은 'NSInvalidArgumentException'을 발생 시켰습니다. 이유는 다음과 같습니다. '- [PFFile size] : 인식 할 수없는 선택기 오류 – Marcus
실제로 테이블을 다시로드하려고하기 때문에 오류가 발생하지만 코드의 다른 부분에 오류가 있습니다. 귀하의 질문에 PFFile을 사용하는 코드가 보이지 않습니다. – rdelmar