问题
I am working on IOS application.Integrated Dropbox successfully and saving data as record in datastores in DropBox as well.It was fine till here.But I am unable to get data after deleting application and reinstalling it.But in one scenario I am getting data i.e,"I inserted a record in any one of the tables in datastores,after inserting that when I am trying to get data Its coming successfully".But I need to get for the first time as the app installs.If any one worked on it please help me.Thanks in advance.
-(void)dropBoxScuccessLogin:(NSString *)successString
{
if ([successString isEqualToString:@"scuccess"])
{
//appdelegate.window.rootViewController = appdelegate.splitview;
NSArray *array1=[appdelegate.datastoreManager listDatastores:nil];
NSLog(@"array is %@",array1);
if (self.account)
{
NSDate *mydate=[NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMM-DD-yyyy hh:mm:ss a"];
NSString *stringFromDate = [formatter stringFromDate:mydate];
DBTable *customerTbl = [self.store getTable:@"DataSyncedOndate"];
DBRecord *task = [customerTbl insert:@{ @"SyncedDate": stringFromDate} ];
__weak DropBoxViewController *slf = self;
[self.store addObserver:self block:^ {
if (slf.store.status & (DBDatastoreIncoming | DBDatastoreOutgoing))
{
[self syncTasks];
}
}];
[self.store sync:nil];
}
}
else
{
NSLog(@"Dropbox Login faild");
}
}
- (void)syncTasks
{
NSLog(@"Self Account is in syncTasks is %@",self.account);
if (self.account)
{
NSDictionary *changed = [self.store sync:nil];
NSLog(@" Data is Synced");
// [self getDataSync];
dispatch_async(dispatch_get_main_queue(), ^{
[self retriveDataFromDB];
});
// [self performSelector:@selector(getDataSync) withObject:nil afterDelay:2.0];
}
else
{
// [alertView show];
}
}
in retriveDataFromDB method
-(void)retriveDataFromDB
{
NSLog(@"retrive from DB method called");
///////////Admin details///////////
NSMutableArray *tasks = [NSMutableArray arrayWithArray:[[self.store getTable:@"PriceList"] query:nil error:nil]];
NSLog(@"tasks count is %d",[tasks count]);
for (int k=0; k<[tasks count]; k++)
{
DBRecord *recordObj=[tasks objectAtIndex:k];
NSString *Tier1_Id =recordObj[@"Tier1"];
NSString *Tier2_Id =recordObj[@"Tier2"];
NSString *Tier3_Id =recordObj[@"Tier3"];
NSString *Code_Id =recordObj[@"Code"];
NSString *CRV_Id =recordObj[@"CRV"];
NSString *insertAdminString = [NSString stringWithFormat:@"INSERT INTO admin_Tbl(Code,Tier1,Tier2,Tier3,CRV) VALUES(\"%@\",\"%@\",\"%@\",\"%@\",\"%@\")",Code_Id,Tier1_Id,Tier2_Id,Tier3_Id,CRV_Id];
BOOL isDataadded = [appdelegate executeInsertQuery:insertAdminString];
if (isDataadded == YES)
{
NSLog(@"admin table insertrd successfully");
}
else
{
NSLog(@"admin table not insertrd successfully");
}
}
}
In Log I am getting tasks count is "0".
来源:https://stackoverflow.com/questions/21347592/unable-to-get-data-from-dropbox-in-ios