This file contains hidden or 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
[MagicalRecord saveWithBlock:^(NSManagedObjectContext * localContext) { | |
NSArray * array = [CoopBoxStorage findAllWithPredicate:predicate inContext:localContext]; | |
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * stop) { | |
CoopBoxStorage * coopBoxStorage = obj; | |
[coopBoxStorage MR_deleteEntityInContext:localContext]; | |
}]; | |
} completion:^(BOOL success, NSError * error) { | |
if (success) { | |
DDLogInfo(@"CoopBoxStorage stored on database without errors"); |
This file contains hidden or 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
- (UIImage *) imageWithUIView:(UIView *)view { | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale); | |
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
This file contains hidden or 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
UIDatePicker *datePicker = [[UIDatePicker alloc] init]; | |
datePicker.datePickerMode = UIDatePickerModeDateAndTime; | |
datePicker.minimumDate = [NSDate date]; | |
datePicker.maximumDate = [NSDate dateWithTimeInterval:(24*60*60*2) sinceDate:datePicker.minimumDate]; | |
datePicker.minuteInterval = 10; | |
datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//设置为中文显示 | |
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; | |
[alert.view addSubview:datePicker]; |
This file contains hidden or 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
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
if ([segue.identifier isEqualToString:@"0"]) { | |
UINavigationController * nav = segue.destinationViewController; | |
LaunchTongChengTableViewController * vc = (LaunchTongChengTableViewController *)nav.topViewController; | |
if ([vc respondsToSelector:@selector(setScenarioType:)]) { | |
vc.scenarioType = 0; | |
} | |
} | |
} |
This file contains hidden or 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
- (BOOL)isModal { | |
return self.presentingViewController.presentedViewController == self | |
|| self.navigationController.presentingViewController.presentedViewController == self.navigationController | |
|| [self.tabBarController.presentingViewController isKindOfClass:[UITabBarController class]]; | |
} |
This file contains hidden or 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
- (UIStoryboard *)mainStoryboard | |
{ | |
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" | |
bundle:[NSBundle mainBundle]]; | |
return storyboard; | |
} |
This file contains hidden or 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
- (void)addTaskButtonClicked:(id)sender | |
{ | |
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"NewTaskTitle", @"") | |
message:@"" | |
delegate:self | |
cancelButtonTitle:NSLocalizedString(@"NewTaskCancel", @"") | |
otherButtonTitles:NSLocalizedString(@"NewTaskConfirm", @""), nil]; | |
alertView.delegate = self; | |
alertView.tag = 0; | |
alertView.alertViewStyle = UIAlertViewStylePlainTextInput; |
This file contains hidden or 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
//计算NSString中英文字符串的字符长度。ios 中一个汉字算2字符数 | |
- (int)charNumber:(NSString*)strtemp | |
{ | |
int strlength = 0; | |
char* p = (char*)[strtemp cStringUsingEncoding:NSUnicodeStringEncoding]; | |
for (int i = 0; i < [strtemp lengthOfBytesUsingEncoding:NSUnicodeStringEncoding]; i++) { | |
if (*p) { | |
p++; | |
strlength++; | |
} else { |
This file contains hidden or 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
+ (NSDate*)_getDateBySecondFormat:(NSDate*)date | |
{ | |
return [self _getDateByFormat:date | |
Format:@"yyyy/MM/dd HH:mm"]; | |
} | |
+ (NSDate*)_getDateByFormat:(NSDate*)date Format:(NSString*)format | |
{ | |
NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:format]; |