Skip to content

Instantly share code, notes, and snippets.

View markSci5's full-sized avatar

Mark Dhem S. Mansueto markSci5

View GitHub Profile
@Marlunes
Marlunes / hide_status_bar
Created July 16, 2013 07:54
FORCE HIDE STATUS BAR FOR IOS 7 AND 6
//viewDidload
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
@Marlunes
Marlunes / Core_data_migration
Created July 9, 2013 09:03
CORE DATA MIGRATION
//in AppDelegate.m
// Add this inside NSPersistenStoreCoordinator delegate
/* Note: NSPersistenStoreCoordinator delegate is automatically created if you create
empty application and selected "use Core Data"
*/
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
@Marlunes
Marlunes / sqlite_addDB
Created July 4, 2013 07:01
ADDING SQLite DATABASE
//all stuffs will be on the Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//some appdelegate codes here......
[self checkDatabaseIfExists]; //Makes sure that the app has a database
//some appdelegate codes here ......
@Marlunes
Marlunes / fetch_request
Created July 4, 2013 06:36
FETCH REQUEST
/*
To call:
myArray = [self fetchDataWithEntityName:@"Employees" withSortDescriptorKey:@"name" withPredicateFormat:[NSPredicate predicateWithFormat:@"employee == %@", myEmployeeName];
*/
- (NSArray *)fetchDataWithEntityName:(NSString *)entityName withSortDescriptorKey:(NSString *) sortDescriptorKey withPredicateFormat:(NSPredicate *)predicateFormat{
NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:context];
@Marlunes
Marlunes / resize_image
Created July 4, 2013 06:24
RESIZING IMAGE PROPORTIONALLY
/* To call:
resizedImage = [self imageByScalingProportionallyToSize:myImageView.size usingImage:myImage];
*/
//Method:
- (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize usingImage:(UIImage *)image{
UIImage *sourceImage = image;
@markSci5
markSci5 / MySingleton.h
Created July 2, 2013 02:50
iOS Singleton
#import <Foundation/Foundation.h>
@interface MySingleton : NSObject
- (id)sharedInstance;
@end