I have an application based on the documents and I would like that when you create a new file the tableview are pre-populated with default data. I did the following:
- I launched my application and I populated the tables, then I saved the file
Untitled.sqlite
- I imported the file
Untitled.sqlite
between the resources of my application - I inserted the following code in the following file
MyApplicationDocumente.m:
- (id)init {
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:@"/Users/andreabollini/Library/Developer/Xcode/DerivedData/Preventivi-euqsrtroavapbwfjvljrxamywbvf/Build/Products/Debug/Preventivi.app/Contents/Resources/en.lproj"]) {
NSString *defaultStorePath = [[NSBundle mainBundle]
pathForResource:@"Untitled" ofType:@"sqlite"];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:@"/Users/andreabollini/Library/Developer/Xcode/DerivedData/Preventivi-euqsrtroavapbwfjvljrxamywbvf/Build/Products/Debug/Preventivi.app/Contents/Resources/en.lproj" error:NULL];
[tabella1 reloadData];
[tabella2 reloadData];
}
}
}
return self;}
There are no errors, but it does not work. When I open the application, the tableview remains empty and nothing happens. What's wrong?