Books
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
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"ck" | |
ofType:@"pem"]; | |
NSData *p12data = [NSData dataWithContentsOfFile:certificatePath]; | |
NSString *apnsToken = [p12data base64EncodedString]; | |
NSDictionary *parameters = @{@"apnsToken": apnsToken}; |
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
enum SimpleEnum : ExampleProtocol { | |
case Base, Adjusted | |
var simpleDescription: String { | |
get { | |
return self.getDescription() | |
} | |
} | |
func getDescription() -> String { |
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
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 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
func handleKeyboardWillShowNotification(notification: NSNotification) { | |
if self.inputContainerViewBottomLayoutGuideConstraint.constant == 0 { | |
keyboardWillChangeFrameWithNotification(notification, showKeyboard: true) | |
scrollBubbleTableViewToBottomAnimated(true) | |
} | |
} | |
func handleKeyboardWillHideNotification(notification: NSNotification) { | |
if self.inputContainerViewBottomLayoutGuideConstraint.constant > 0 { | |
keyboardWillChangeFrameWithNotification(notification, showKeyboard: false) |
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
private func addListBubbleCellsWithCount(count: Int) { | |
var contentOffset = self.tableView.contentOffset | |
UIView.setAnimationsEnabled(false) | |
var indexPaths = [NSIndexPath]() | |
var heightForNewRows: CGFloat = 0 | |
for var i = 0; i < count; i++ { | |
let indexPath = NSIndexPath(forRow: i, inSection: 0) |
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
class LINJSONHelper { | |
class func jsonStringWithObject(obj: AnyObject) -> String? { | |
var error: NSError? | |
let jsonData = NSJSONSerialization.dataWithJSONObject(obj, options: NSJSONWritingOptions(0), error: &error) | |
if error != nil { | |
println("Error creating JSON data: \(error!.description)"); | |
return nil | |
} | |
return NSString(data: jsonData, encoding: NSUTF8StringEncoding) |
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
NSArray* array = [UIApplication sharedApplication].windows; | |
for(id windowObject in array){ | |
NSString* class = NSStringFromClass([windowObject class]); | |
if([class isEqualToString:@"UITextEffectsWindow"]){ | |
UIWindow* keyboardWindow = (UIWindow*)windowObject; | |
keyboardWindow.windowLevel = self.view.window.windowLevel+1; | |
} | |
} |
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
// Indicate != nil instead of bool | |
if navigationController { | |
} | |
if navigationController != nil { | |
} | |
// Use require keywork for require methods |
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
+ (id)objectForKey:(NSString *)key | |
{ | |
if ([key length] == 0) { | |
return nil; | |
} | |
NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:key]; | |
if (!data) { | |
return nil; | |
} |