Надеюсь, кто-нибудь может помочь мне получить этот код, работающий с Parse.com в приложении iOS.PFQuery текущих пользовательских объектов
У меня есть таблица, которая запрашивает класс Parse.com под названием Channel с 5 основными столбцами.
- Один: "ObjectId"
- Два: "владелец", который является указателем < _User (основной класс)>
- Третье: "Название"
- Четвертое: "О"
- Пятый : «image»
Мне нужно запросить в таблицу только те каналы «имя», «около» и «изображение», которые были созданы конкретным пользователем.
В моем коде метод queryForTable не работает, когда я пытаюсь выполнить [query whereKey: @ "name" equalTo: [PFUser currentUser] .objectId] (в настоящее время прокомментировано ниже). Текущий ACL для всех столбцов - Public Read.
Мой текущий код выглядит следующим образом:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
self.parseClassName = @"Channel";
//self.textKey = @"name";
self.pullToRefreshEnabled = YES;
self.paginationEnabled = YES;
self.objectsPerPage = 5;
}
return self;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//self.canSearch = 0;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
#pragma mark - Table view data source
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {//
//#warning Potentially incomplete method implementation.
// Return the number of sections.
// return 0;
//}
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//#warning Incomplete method implementation.
// Return the number of rows in the section.
//}
#pragma mark - PFQueryTableViewController
#pragma mark - Query
- (PFQuery *)queryForTable
{
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
//[query whereKey:@"name" equalTo:[PFUser currentUser].objectId];
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
return query;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
static NSString *CellIdentifier = @"Cell";
MyChanTableViewCell *cell = (MyChanTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell
PFFile *thumbnail = [object objectForKey:@"image"];
PFImageView *thumbnailImageView = (PFImageView*)cell.showImage;
thumbnailImageView.image = [UIImage imageNamed:@"Image.jpg"];
thumbnailImageView.file = thumbnail;
[thumbnailImageView loadInBackground];
cell.mainTitle.text = [object objectForKey:@"name"];
cell.detail.text = [object objectForKey:@"about"];
return cell;
}
// Set CellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForNextPageAtIndexPath:(NSIndexPath *)indexPath {
static NSString *LoadMoreCellIdentifier = @"LoadMoreCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LoadMoreCellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LoadMoreCellIdentifier];
}
return cell;
}
// Set TableView Height for Load Next Page
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if([self.objects count] == indexPath.row) {
// Load More Cell Height
return 60.0;
} else {
return 80.0;
}
}
Какое-либо значение в столбце имен равно идентификатору объекта? –
Нет, значения в столбце имен являются строками, и есть столбец objectId со своими случайными значениями, назначенными Parse –
Привет @LyndseyScott thanx для ответа. Нет, значения в столбце имен являются строками, и есть столбец objectId с его случайными значениями, назначенными Parse –