我想從parse.com加載我的表視圖中的數據,但表視圖加載但沒有數據。類名是@「Exibitor」,但沒有加載。parse.com tableview不加載對象
@interface DMKViewControllerExhibitors()
@end
@implementation DMKViewControllerExhibitors
- (id)initWithCoder:(NSCoder *)aCoder {
self = [super initWithCoder:aCoder];
if (self) {
// Customize the table
// The className to query on
self.parseClassName = @"Exibitor";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"objectid";
// Uncomment the following line to specify the key of a PFFile on the PFObject to display in the imageView of the default cell style
// self.imageKey = @"image";
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = YES;
// The number of objects to show per page
self.objectsPerPage = 25;
}
return self;
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[super viewDidAppear:animated];
self.canDisplayBannerAds = YES;
#pragma mark - Parse
- (void)objectsDidLoad:(NSError *)error {
[super objectsDidLoad:error];
// This method is called every time objects are loaded from Parse via the PFQuery
}
- (void)objectsWillLoad {
[super objectsWillLoad];
// This method is called before a PFQuery is fired to get more objects
}
// Override to customize what kind of query to perform on the class. The default is to query for
// all objects ordered by createdAt descending.
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByAscending:@"name"];
return query;
}
// Override to customize the look of a cell representing an object. The default is to display
// a UITableViewCellStyleDefault style cell with the label being the first key in the object.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Configure the cell
cell.textLabel.text = [object objectForKey:@"text"];
cell.detailTextLabel.text = [NSString stringWithFormat:@"name: %@", [object objectForKey:@"name"]];
return cell;
}
我是新來解析,不能真正看到它爲什麼不加載。 我需要它按降序列出所有名稱。
我現在已經把這個ini和它拋出一個錯誤
*終止應用程序由於未捕獲的異常「NSInternalInconsistencyException」,理由是:「這個查詢有一個優秀的網絡連接。你必須等到它完成。「 *第一擲調用堆棧:
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:@"Exibitor"];
[query whereKey:@"Trade" equalTo:@"True"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded.
NSLog(@"Successfully retrieved %lu scores.", (unsigned long)objects.count);
// Do something with the found objects
for (PFObject *object in objects) {
NSLog(@"%@", object.objectId);
}
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}]; return query;
}
查看帖子底部的更新 –
查看我的回答如何開始,「也許你錯過了粘貼...」。我想你錯過了粘貼。從錯誤中看來,queryForTable方法已經有一個調用者。通過將該代碼添加到該方法中,您可以調用它兩次。 – danh
我只在代碼中擁有queryForTable,只要新的粘貼是代碼中的唯一代碼 –