Select to view content in your preferred language

How to open local geodatabase?

3389
1
Jump to solution
11-09-2015 10:56 PM
ItthisakPhueaksri
Deactivated User

I use Xcode to create a project for load a geodatabase but I cannot access a geodatabase which shares with arcmap.

It throws an exception when I try to get feature tables.

NSString *path = [[NSBundle mainBundle] pathForResource:@"newplan" ofType:@"geodatabase"];
    
    
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *docPath = [documentsDirectory stringByAppendingPathComponent:@"newplan.geodatabase"];
    
    if (![fileManager fileExistsAtPath:docPath])
    {
        [fileManager copyItemAtPath:path toPath:docPath error:&error];
    }
    
    if([fileManager fileExistsAtPath:docPath])
    {
        AGSGDBGeodatabase *gdb = [[AGSGDBGeodatabase alloc] initWithPath:docPath error:&error];
        NSLog(@"%@",gdb.featureTables);
    }
0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

You should check the contents of the error object after line 15. It could give you an indication of why the geodatabase did not open.

But note that you should just be able to use geodatabaseWithName:error: since you're distributing it with the bundle (read only).

View solution in original post

0 Kudos
1 Reply
Nicholas-Furness
Esri Regular Contributor

You should check the contents of the error object after line 15. It could give you an indication of why the geodatabase did not open.

But note that you should just be able to use geodatabaseWithName:error: since you're distributing it with the bundle (read only).

0 Kudos