Harsh
Harsh

Reputation: 666

problem in importing sqlite to coredata

I have implemented coredata in my app.

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [self applicationDocumentsDirectory];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"iBountyHunter.sqlite"];

This gives me error -[NSURL stringByAppendingPathComponent:]: unrecognized selector sent to instance 0x4d394a0'

I tried to find solution, but could not find perfect solution. How to solve this? Thanks in advance.

Upvotes: 0

Views: 234

Answers (2)

Shrey
Shrey

Reputation: 1977

Sanna is Correct..

Try this code.

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"iBountyHunter.sqlite"];

Upvotes: 4

sanna
sanna

Reputation: 1165

Your applictionDocumentsDirectory is returning a NSURL not a NSString, so the third line is trying to call stringByAppendingPathComponent on an NSURL-object.

Upvotes: 2

Related Questions