Search code examples
iosobjective-cyapdatabase

YAPdatabase connexion is null


I try to install yapdatabase on my project and i have the problem that self.connexion is null.

@implementation DataManager

- (instancetype)init {
    self = [super init];
    if (self) {
        self.database = [[YapDatabase alloc] initWithPath:@"myDtabase.sqlite"];
        self.connexion = [self.database newConnection];  
    }
    return self;
}

-(NSMutableArray *)getArtists {
    NSLog(@"%@", self.connexion);
}

What's wrong ?


Solution

  • You need to properly construct the path to the database file:

    [[NSBundle mainBundle] pathForResource:@"myDtabase.sqlite" ofType:nil]
    

    This is a required step to access the resources bundled within your app on iOS.