Books
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
| Solution 1: | |
| NSMangedObjectContext *temporaryContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; | |
| temporaryContext.parentContext = mainMOC; | |
| [temporaryContext performBlock:^{ | |
| // do something that takes some time asynchronously using the temp context | |
| // push to parent | |
| NSError *error; |
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
| enum SimpleEnum : ExampleProtocol { | |
| case Base, Adjusted | |
| var simpleDescription: String { | |
| get { | |
| return self.getDescription() | |
| } | |
| } | |
| func getDescription() -> String { |
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* filePath = [[NSBundle mainBundle] pathForResource:@"ck" | |
| ofType:@"pem"]; | |
| NSData *p12data = [NSData dataWithContentsOfFile:certificatePath]; | |
| NSString *apnsToken = [p12data base64EncodedString]; | |
| NSDictionary *parameters = @{@"apnsToken": apnsToken}; |
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)sendEmailWithReferral:(Referral *)referral completionBlock:(NetworkCompletionBlock)completion { | |
| [[NetworkHelper sharedInstance] updateEmailAuthorizationForRequestHeader]; | |
| NSString *appName=[[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey]; | |
| NSString *message = [NSString stringWithFormat:@"Hi %@\nI found this interesting. You can join %@ and get discount at http://quickref.io/app/%@?code=%@", referral.name, appName, kGroupID, referral.code]; | |
| [[NetworkHelper sharedInstance] POST:@"https://api.mailgun.net/v3/quickref.io/messages" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { | |
| [formData appendPartWithFormData:[@"[email protected]" dataUsingEncoding:NSUTF8StringEncoding] name:@"from"]; | |
| [formData appendPartWithFormData:[referral.consentEmail dataUsingEncoding:NSUTF8StringEncoding] name:@"to"]; | |
| [formData appendPartWithFormData:[message dataUsingEncoding:NSUTF8StringEncoding] name:@"text"]; |
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)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { | |
| SmoothLineView *smoothLineView = (SmoothLineView *)[self.tableFooterView viewWithTag:SMOOTH_LINE_VIEW_TAG]; | |
| CGRect smoothLineViewFrame = [smoothLineView convertRect:self.tableFooterView.bounds toView:self]; | |
| CGPoint touchedPoint = [gestureRecognizer locationInView:self]; | |
| BOOL result = !CGRectContainsPoint(smoothLineViewFrame, touchedPoint); | |
| return result; | |
| } |
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
| It's worth noting that if you want a currently-focused field to update the keyboard type immediately, there's one extra step: | |
| // textField is set to a UIKeyboardType other than UIKeyboardTypeEmailAddress | |
| [textField setKeyboardType:UIKeyboardTypeEmailAddress]; | |
| [textField reloadInputViews]; |
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
| http://stackoverflow.com/questions/18368567/uitableviewcell-with-uitextview-height-in-ios-7 | |
| - (void)textViewDidChange:(UITextView *)textView { | |
| if ([textView getContentHeight] > 31) { | |
| self.noteHeightLayoutConstraint.constant = [textView getContentHeight] + 20; | |
| [self.tableView beginUpdates]; | |
| [self.tableView endUpdates]; | |
| [self scrollToCursorForTextView:textView]; | |
| } |
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)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename | |
| { | |
| // Creates a mutable data object for updating with binary data, like a byte array | |
| NSMutableData *pdfData = [NSMutableData data]; | |
| // Points the pdf converter to the mutable data object and to the UIView to be converted | |
| UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil); | |
| UIGraphicsBeginPDFPage(); | |
| CGContextRef pdfContext = UIGraphicsGetCurrentContext(); | |
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
| if #available(iOS 8.0, *) { | |
| let alertController = UIAlertController(title: "Terms & Conditions", message: kTermsAndConditions, preferredStyle: .Alert) | |
| let OKAction = UIAlertAction(title: "OK", style: .Cancel) { (action) in | |
| alertController.dismissViewControllerAnimated(true, completion: nil) | |
| } | |
| alertController.addAction(OKAction) | |
| let paragraphStyle = NSMutableParagraphStyle() | |
| paragraphStyle.alignment = NSTextAlignment.Left | |