Skip to content

Instantly share code, notes, and snippets.

View FlaviuSim's full-sized avatar

Flaviu Simihaian FlaviuSim

View GitHub Profile
@FlaviuSim
FlaviuSim / gist:2313087
Created April 5, 2012 18:30
appFinishLaunchingWithOptions for seeding your CoreData with RestKit
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize RestKit
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://twitter.com"];
// Enable automatic network activity indicator management
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
// Initialize object store
#ifdef RESTKIT_GENERATE_SEED_DB
NSString *seedDatabaseName = nil;
@FlaviuSim
FlaviuSim / gist:2313078
Created April 5, 2012 18:29
appFinishLaunchingWithOptions for seeding your CoreData with RestKit
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize RestKit
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://twitter.com"];
// Enable automatic network activity indicator management
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
// Initialize object store
#ifdef RESTKIT_GENERATE_SEED_DB
NSString *seedDatabaseName = nil;
@FlaviuSim
FlaviuSim / gist:2312991
Created April 5, 2012 18:20
appFinishLaunchingWithOptions for seeding your CoreData with RestKit
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize RestKit
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://twitter.com"];
// Enable automatic network activity indicator management
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
// Initialize object store
#ifdef RESTKIT_GENERATE_SEED_DB
NSString *seedDatabaseName = nil;
@FlaviuSim
FlaviuSim / gist:2312969
Created April 5, 2012 18:17
appFinishLaunchingWithOptions for seeding your CoreData with RestKit
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize RestKit
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://twitter.com"];
// Enable automatic network activity indicator management
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
// Initialize object store
#ifdef RESTKIT_GENERATE_SEED_DB
@FlaviuSim
FlaviuSim / gist:2312968
Created April 5, 2012 18:17
appFinishLaunchingWithOptions for seeding your CoreData with RestKit
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize RestKit
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://twitter.com"];
// Enable automatic network activity indicator management
objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
// Initialize object store
#ifdef RESTKIT_GENERATE_SEED_DB
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// get the table and search bar bounds
CGRect tableBounds = self.tableView.bounds;
CGRect searchBarFrame = self.searchBar.frame;
// make sure the search bar stays at the table's original x and y as the content moves
self.searchBar.frame = CGRectMake(tableBounds.origin.x,
tableBounds.origin.y,
searchBarFrame.size.width,
@interface DrugSearchViewController() <UITableViewDelegate, UISearchBarDelegate, UIScrollViewDelegate>
@end
NSError *error = nil;
NSURL *storeURL = [NSURLfileURLWithPath:storePath];
__persistentStoreCoordinator = [[NSPersistentStoreCoordinatoralloc] initWithManagedObjectModel:[selfmanagedObjectModel]];
if (![__persistentStoreCoordinatoraddPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:storeURL options:nilerror:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
NSLog(@"Final Store path is: %@", [storeURL path]);
return__persistentStoreCoordinator
NSError *error = nil;
NSURL *storeURL = [NSURLfileURLWithPath:storePath];
__persistentStoreCoordinator = [[NSPersistentStoreCoordinatoralloc] initWithManagedObjectModel:[selfmanagedObjectModel]];
if (![__persistentStoreCoordinatoraddPersistentStoreWithType:NSSQLiteStoreTypeconfiguration:nilURL:storeURL options:nilerror:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
NSLog(@"Final Store path is: %@", [storeURL path]);
return__persistentStoreCoordinator
NSString *storePath = [[[selfapplicationDocumentsDirectory] URLByAppendingPathComponent: @"CoreDataStore.sqlite"] path];
// Check if the store exists in.
if (![[NSFileManagerdefaultManager] fileExistsAtPath:storePath]) {
// copy the payload to the store location.
NSString *bundlePath = [[NSBundlemainBundle] bundlePath];
NSString *bundleStore = [bundlePath stringByAppendingPathComponent:@"persistentStore"];
NSError *error = nil;
[[NSFileManagerdefaultManager] copyItemAtPath:bundleStore toPath:storePath error:&error];