희망이 누구든지이 코드는 iOS 응용 프로그램의 Parse.com에서 작동하도록 할 수 있습니다.PFQuery 현재 사용자 특정 개체
5 개의 기본 열이있는 채널이라는 Parse.com 클래스에 쿼리하는 테이블이 있습니다.
- 하나 "OBJECTID"
- 2 :
- 다섯 번째 "에 대해": "이름"
- 넷째 : 포인터 < _USER (기본 클래스)>
- 셋째는 "소유자" : "image"
현재 사용자가 지정한 채널 "name", "about"및 "image"만 테이블에 쿼리해야합니다.
내 코드에서 [query whereKey : @ "name"equalTo : [PFUser currentUser] .objectId] (현재 아래에 설명되어 있음)를 시도하면 queryForTable 메서드가 작동하지 않습니다. 모든 열의 현재 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;
}
}
name 열에있는 값 중 하나라도 개체 ID와 같습니까? –
아니요, name 열의 값은 string이고 Parse에 의해 할당 된 임의 값이있는 objectId 열이 있습니다 –
안녕하세요 @LyndseyScott은 답장을 보내 주려고합니다. 아니요, name 열의 값은 string이며 Parse가 할당 한 임의의 값이있는 objectId 열이 있습니다. –