parse.com PFQueryTableViewController 은 동일한 오브젝트를 여러 번
-
20-12-2019 - |
문제
그 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
사용자 정의의 디스플레이 PFObject
의 데이터 PFQueryTableViewController
.그래서 나는 내 건 PFQuery
체에서 (PFQuery *)queryForTable
나 PFQueryTableViewController
delegate
을 얻을 여러 개체들에서 NSArray
.
내 생각에는 parse.com 을 보내/통화 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
한 번에 대한 각각의 개체 반환됩니다.그러나 내가 찾는 돌아 동 체가 여러 번 나옵니다.
따라서,예를 들어,3 개의 다른 물체에 대한 3 시간 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
라고,나는 같은 개체입니다.하지만 그것은 문제 또는 데이터 쿼리기 때문에,말 (PFQuery *)queryForTable
기
return query;
나
[query findObjectsInBackgroundWithBlock:^(NSArray *resultsNow,NSError *error) {NSLog(@"We have the following: %@", resultsNow);}];
sleep(5);
이것을 보여줍 3 객체를 얻습니다.어떻게 정확한 동 면 쿼리하여 처리 PFQueryTableViewController
전화 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
3 시간을 보내는 대신 3 개체를 하나씩,그것을 보낸 첫 번째 중 하나 3 회?
에 대응하여 북두칠성의 질문에,나는 추가 어떤 답을 의견에,하지만 또한 다음과 같은 관련 보인:
- (PFObject *)objectAtIndex:(NSIndexPath *)indexPath {
// overridden, since we want to implement sections
if (indexPath.section < self.objects.count) {
return [self.objects objectAtIndex:indexPath.section];
}
return nil;
}
해결책 2
덕분에 북두칠성의 문제,나는 로그인 objectsDidLoad:는 것을 발견하고 올바른 3 개체로드,그래서 그것은 문제의 PFQueryTableViewController 지 않을 로드하는 순서 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
.
특히,이 매핑되어 있었에 -(PFObject *)objectAtIndex:(NSIndexPath *)indexPath
으로 표시된다.그러나를 찾고에 대한 설명서를 참조 N 번째 시간을,내가 갑자기 주 메서드 이름이 실제로 합 -(PFObject *)objectAtIndexPath:(NSIndexPath *)indexPath
.더 궁금하지 않은 호출되고,나 매핑되었으로 오는 효과가 있고,따라서 잘못된 개체가 전달되고 있음 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
.을 때 나는 그것을 변경하기 -(PFObject *)objectAtIndexPath:(NSIndexPath *)indexPath
, 문제 멀리 갔다!
어떻게 내가 잘못된 방법 이름?내가 찾는 것을 복사한 매핑에서 예를 anypic 코드,그래서 나는 parse.com 변경된 메서드 이름이 언젠가 후 anypic 작성되었?할 수 있는지 확인하는 사람이 있는?내가 사용하여 분석 framework1.2.14
다른 팁
나는 유사한 문제는 무엇이었:
1-를 사용하는 대신 PFQueryTableViewController
그냥 일반 사용 UITableViewController
.
2 변경 방법 queryForTable:
하기 (void)
.
- (void)queryForTable {
3 삭제 PFQueryTableView
방법 및 구현 DataSource
방법이 있습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
}
전화 [self queryForTable]
에 viewDidLoad
후 선언합니다.h 파일입니다.
를 사용하지 않는 경우,당신은 단지 만들기 NSArray
property
고 채우에 queryForTable
:
self.yourarray = [query findobjects];
당신이 사용하는 경우 블록는지 확인,당신은 채우 NSArray
내부 블록을 다시 tableview.
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
// There was an error, do something with it.
}
else {
self.yourArray = objects;
}
// Reload your tableView Data
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}];
이것은 제가 어떻게 여기까지 왔는지 그것을 작동합니다.도움이 되기를 바랍니다.