This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface MySingleton : NSObject | |
- (id)sharedInstance; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* To call: | |
resizedImage = [self imageByScalingProportionallyToSize:myImageView.size usingImage:myImage]; | |
*/ | |
//Method: | |
- (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize usingImage:(UIImage *)image{ | |
UIImage *sourceImage = image; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 ...... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//viewDidload | |
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { | |
// iOS 7 | |
[self prefersStatusBarHidden]; | |
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; | |
} else { | |
// iOS 6 | |
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; | |
} |