解析查询检索 NSNumber 堆栈中的下一个对象
Parse Query Retrieving Next Object in NSNumber Stack
我正在尝试从我的解析中检索下一组解析数据 class,但我完全停滞不前,无法完成我正在尝试做的事情。
示例用户从提示 #1 开始,然后按下一步并显示提示 #2,依此类推。
我在我的 "Next" 按钮上有一个解析查询,它应该将解析中的下一个提示加载到我的名为 tipBody 的 UILabel 中,并将下一个连续的提示编号加载到我的 tipNumber 标签中。
- (IBAction)nextTipAction:(id)sender
{
[ProgressHUD show:@"Loading Next Tip"];
//Get Current Comments//
__weak typeof (self) weakSelf = self;
PFQuery *query = [PFQuery queryWithClassName:@"Archive"];
[query whereKey:@"body" equalTo:@"tipNumber"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
weakSelf.tipNumberLabel.text =[NSString stringWithFormat:@"Tip Number: %ld", [[weakSelf.currentTip objectForKey:@"tipNumber"] integerValue]];
[self.currentTip incrementKey:@"tipNumber" byAmount:@+1];
[ProgressHUD dismiss];
}
else
{
[ProgressHUD dismiss];
[ProgressHUD showError:@"Sorry! Unable to load Tips"];
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
非常感谢任何帮助!谢谢!
检查您的代码如下。
- (IBAction)nextTipAction:(id)sender
{
NextTipNumber++; // Assume that on didload it initiate to 1 and also load on view didload you have load first tip.
[ProgressHUD show:@"Loading Next Tip"];
//Get Current Comments//
__weak typeof (self) weakSelf = self;
PFQuery *query = [PFQuery queryWithClassName:@"Archive"];
[query orderByAscending:@"tipNumber"];
[query setLimit: NextTipNumber]; // Set the limit according which tip you want to access
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
PFObject *ArchiveObject = [objects lastObject];
weakSelf.tipNumberLabel.text = [ArchiveObject objectForKey:@"tipNumber"];
weakSelf.tipBody.text = [ArchiveObject objectForKey:@"body"];
[ProgressHUD dismiss];
}
else
{
[ProgressHUD dismiss];
[ProgressHUD showError:@"Sorry! Unable to load Tips"];
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
我正在尝试从我的解析中检索下一组解析数据 class,但我完全停滞不前,无法完成我正在尝试做的事情。
示例用户从提示 #1 开始,然后按下一步并显示提示 #2,依此类推。
我在我的 "Next" 按钮上有一个解析查询,它应该将解析中的下一个提示加载到我的名为 tipBody 的 UILabel 中,并将下一个连续的提示编号加载到我的 tipNumber 标签中。
- (IBAction)nextTipAction:(id)sender
{
[ProgressHUD show:@"Loading Next Tip"];
//Get Current Comments//
__weak typeof (self) weakSelf = self;
PFQuery *query = [PFQuery queryWithClassName:@"Archive"];
[query whereKey:@"body" equalTo:@"tipNumber"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
weakSelf.tipNumberLabel.text =[NSString stringWithFormat:@"Tip Number: %ld", [[weakSelf.currentTip objectForKey:@"tipNumber"] integerValue]];
[self.currentTip incrementKey:@"tipNumber" byAmount:@+1];
[ProgressHUD dismiss];
}
else
{
[ProgressHUD dismiss];
[ProgressHUD showError:@"Sorry! Unable to load Tips"];
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
非常感谢任何帮助!谢谢!
检查您的代码如下。
- (IBAction)nextTipAction:(id)sender
{
NextTipNumber++; // Assume that on didload it initiate to 1 and also load on view didload you have load first tip.
[ProgressHUD show:@"Loading Next Tip"];
//Get Current Comments//
__weak typeof (self) weakSelf = self;
PFQuery *query = [PFQuery queryWithClassName:@"Archive"];
[query orderByAscending:@"tipNumber"];
[query setLimit: NextTipNumber]; // Set the limit according which tip you want to access
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
PFObject *ArchiveObject = [objects lastObject];
weakSelf.tipNumberLabel.text = [ArchiveObject objectForKey:@"tipNumber"];
weakSelf.tipBody.text = [ArchiveObject objectForKey:@"body"];
[ProgressHUD dismiss];
}
else
{
[ProgressHUD dismiss];
[ProgressHUD showError:@"Sorry! Unable to load Tips"];
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}