[英]Parse.com data fetch `NULL` value in iOS
i am newbie to parse.com and try very more time to fetch data from it but give NULL
value each time. 我是parse.com的新手,并尝试了更多时间从中获取数据,但每次都提供NULL
值。 Here, in my Parse table contain 1.89k rows so i want to check all row and Fetch data from it. 在这里,在我的Parse表中包含1.89k行,因此我想检查所有行并从中获取数据。 for data fetch i write a code like as 对于数据获取,我编写了如下代码
-(void)getdata
{
NSMutableArray *allObjects = [[NSMutableArray alloc]init];
NSUInteger limit = 1000;
__block NSUInteger skip = 0;
PFQuery *query = [PFQuery queryWithClassName:@"MapInfo"];
[query whereKey:@"Type" equalTo:@"Business"];
[query whereKey:@"Admin" equalTo:self.bisusername];
[query setLimit: limit];
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
[allObjects addObjectsFromArray:objects];
if (objects.count == limit) {
skip += limit;
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[allObjects addObjectsFromArray:objects];
self.qpinname=[allObjects valueForKey:@"GPIN"];
NSLog(@"Qpin Array %lu",(unsigned long)[self.qpinname count]);
self.locationArray=[allObjects valueForKey:@"Location"];
self.latitude=[self.locationArray valueForKey:@"lat"];
self.longitude=[self.locationArray valueForKey:@"lng"];
self.address=[allObjects valueForKey:@"Address"];
self.usernameArray=[allObjects valueForKey:@"AddedBy"];
self.buildingNameArray=[allObjects valueForKey:@"BuildingName"];
self.businessHourArray=[allObjects valueForKey:@"OfficeTiming"];
self.parkingInfoArry=[allObjects valueForKey:@"Parking"];
self.officenoArray=[allObjects valueForKey:@"DoorNumber"];
NSLog(@"Office Array %@",self.officenoArray);
hudView.hidden=TRUE;
}];
}
}
else
{
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
and when i write a code like as 当我写像这样的代码
-(void)getdata
{
PFQuery *query = [PFQuery queryWithClassName:@"MapInfo"];
[query whereKey:@"Type" equalTo:@"Business"];
[query whereKey:@"Admin" equalTo:self.bisusername];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
self.qpinname=[objects valueForKey:@"GPIN"];
self.locationArray=[objects valueForKey:@"Location"];
self.latitude=[self.locationArray valueForKey:@"lat"];
self.longitude=[self.locationArray valueForKey:@"lng"];
self.address=[objects valueForKey:@"Address"];
self.usernameArray=[objects valueForKey:@"AddedBy"];
self.buildingNameArray=[objects valueForKey:@"BuildingName"];
self.businessHourArray=[objects valueForKey:@"OfficeTiming"];
self.parkingInfoArry=[objects valueForKey:@"Parking"];
self.officenoArray=[objects valueForKey:@"DoorNumber"];
}
else
{
NSString *errorString = [[error userInfo] objectForKey:@"error"];
NSLog(@"Error: %@", errorString);
}
}];
}
Then i got Value from table but it give me value from only one page i want to value from my whole table please give me solution for it Thanks. 然后我从表中获得了价值,但它仅从我要从整个表中获得价值的一页就给了我价值,请给我解决方案。
You aren't iterating the objects array at all. 您根本不需要迭代对象数组。 You are doing something like this: 您正在执行以下操作:
self.qpinname=[allObjects valueForKey:@"GPIN"];
allObjects is an ARRAY not a dictionary. allObjects是一个ARRAY而不是一个字典。 You need to iterate the array and access objects that way. 您需要迭代数组并以这种方式访问对象。 Remember that objects are of the type PFObject that are downloaded from Parse.com. 请记住,对象是从Parse.com下载的PFObject类型。 eg: 例如:
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[allObjects addObjectsFromArray:objects];
for(PFObject *object in allObjects) {
//now you can access things,e.g....
self.locationArray=object[@"Location"];
//and so on...
}
}];
That should fix it. 那应该解决它。 Make sure you are using PFObject above in the loop too. 确保在循环中也使用上面的PFObject。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.