无法从IOS中的Dropbox获取数据

时间:2014-01-25 06:41:14

标签: ios objective-c sync dropbox dropbox-api

我正在开发IOS application.Integrated Dropbox成功并将数据保存为DropBox数据存储中的记录。直到这里都没关系。但是我删除应用程序并重新安装后无法获取数据。但在一个场景中我我正在获取数据,即“我在数据存储区中的任何一个表中插入了一条记录,插入后,当我试图获取数据时它成功”。但我需要第一次获得应用程序安装。如果有的话一个工作的人请帮帮我。谢谢。

-(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方法

-(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");
    }
}

}

在Log中,我得到的任务数为“0”。

0 个答案:

没有答案