Start a new topic

Can't Fetch Data!

HI - I have been beating myself against a wall for two days to get this work and I can't seem to make it happen. After executing the array is nil. Here is the code:

```- (void)viewDidLoad


[super viewDidLoad];

NSLog(@"got to initalizing");

(void) [[KCSClient sharedClient] initializeKinveyServiceForAppKey:@"kid_Te1Hk6PJCO"



if ([KCSUser activeUser] == nil) {

[KCSUser createAutogeneratedUser:^(KCSUser *user, NSError *errorOrNil, KCSUserActionResult result){

NSLog(@"Created User");


} else {

NSLog(@"User was set");


[KCSPing pingKinveyWithBlock:^(KCSPingResult *result) {

if (result.pingWasSuccessful == YES){

NSLog(@"Kinvey Ping Success");

} else {

NSLog(@"Kinvey Ping Failed");



[self loadData];


-(id)loadData {

NSLog(@"fifniashed ping");

// KCSCollection *membersCollection = [KCSCollection collectionFromString:@"usHouse" ofClass:[memberItem class]];

KCSAppdataStore *store = [KCSAppdataStore storeWithOptions:@{ KCSStoreKeyCollectionName : @"usHouse",

KCSStoreKeyCollectionTemplateClass : [memberItem class]}];

[store queryWithQuery:[KCSQuery query] withCompletionBlock:^(NSArray *objectsOrNIl, NSError *errorOrNil) {

if (errorOrNil != nil) {

//An error happened, just log for now

NSLog(@"An error occurred on fetch: %@", errorOrNil);

} else {

//got all events back from server -- update table view



} withProgressBlock:nil];

return objects;


Here is the class definition and key mapping:



@interface memberItem : NSObject

@property (nonatomic, copy) NSString *objectId;

@property (nonatomic, copy) NSString *memberFullName;

@property (nonatomic, copy) NSString *memberFirstName;

@property (nonatomic, copy) NSString *memberLastName;

@property (nonatomic, copy) NSString *memberParty;

@property (nonatomic, copy) NSString *memberDistrict;

@property (nonatomic, copy) NSString *memberState;

import "memberItem.h"


@implementation memberItem

- (NSDictionary *)hostToKinveyPropertyMapping


return @{ @"objectId" : KCSEntityKeyId, @"memberFullName" : @"FullName",

@"memberFirstName" : @"First",

@"memberLastName" : @"Last",

@"memberParty" : @"Party",

@"memberDistrict" : @"District",

@"memberState" : @"State"};



I am sure I am overlooking something completely obvious but I can't get it to work. Any help would be appreciated.

All the best.

Hey Steve, sorry you're having trouble! Were you able to successfully fetch data using the sample apps? I'm just trying to rule out any connection issues.
Yup - made the connection, successfully pinged.

you need to to call the load data after the user completion block is called.
Login or Signup to post a comment