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
NSDate *start = [NSDate date]; | |
NSDate *methodFinish = [NSDate date]; | |
NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:start]; | |
NSLog(@"Execution Time: %f", executionTime); |
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
- (void)refreshData | |
{ | |
PFUser *currentUser = [PFUser currentUser]; | |
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%@ = '%@' OR %@ = '%@'", | |
kMessageUserSendIdKey, currentUser.objectId, | |
kMessageUserReceiveIdKey, currentUser.objectId]]; | |
PFQuery *query = [PFQuery queryWithClassName:kMessageClassKey predicate:predicate]; | |
[query addDescendingOrder:kMessageTimeCreatedKey]; |
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 *predicateFormatString = [NSString stringWithFormat:@"(%@ = '%@' OR %@ = '%@') AND (%@ = '%@' OR %@ = '%@')", | |
kMessageUserSendIdKey, self.currentUser.objectId, | |
kMessageUserSendIdKey, self.userChat.objectId, | |
kMessageUserReceiveIdKey, self.currentUser.objectId, | |
kMessageUserReceiveIdKey, self.userChat.objectId]; |
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
//Start an activity indicator here | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
//Call your function or whatever work that needs to be done | |
//Code in this part is run on a background thread | |
dispatch_async(dispatch_get_main_queue(), ^(void) { | |
//Stop your activity indicator or anything else with the GUI |
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
You need your font in .otf or .ttf copied to your project. For example in Supporting Files. | |
You need to edit .plist file. Add "Fonts provided by application" key into your plist and in Item 0 copy the exact filename of the font you copied to your Supporting files WITH extension. For example: "JosefinSansStd-Light_0.otf" | |
Make sure that the font you imported to your app is being packed into app itself. Do that by selecting your Target, then Build Phases, then Copy Bundle Resources. If you don't see your font in there, drag it from Supporting Files. | |
Finally, you would like to list all your fonts when the app starts just to see useable name for your font. You will do that with this little piece of code: | |
NSArray *fontFamilies = [UIFont familyNames]; | |
for (int i = 0; i < [fontFamilies count]; i++) | |
{ |
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
Also for people referring to @akashivskyy answer, and having trouble or crash with error | |
fatal error: use of unimplemented initializer 'init(coder:)' for class | |
Implementing initWithCoder in Objective-C is not required but in Swift is required | |
So to use @akashivskyy's asnwer you need also to add these lines to your destinationViewController. | |
init(coder aDecoder: NSCoder!) | |
{ |
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
Re-ordering in XCode didn't do the trick; I'm using Cocoapods, which creates a Pods.xcconfig file. This has a OTHER_LDFLAGS line. I put -framework Foundation as the first entry, and that's made my project work. | |
OTHER_LDFLAGS = -framework Foundation -ObjC … | |
http://stackoverflow.com/questions/24043532/dyld-symbol-not-found-nsurlauthenticationmethodclientcertificate-when-trying#answer-24288986 |
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 switchRootViewController(rootViewController: UIViewController, animated: Bool, completion: (() -> Void)?) { | |
if animated { | |
UIView.transitionWithView(window, duration: 0.5, options: .TransitionCrossDissolve, animations: { | |
let oldState: Bool = UIView.areAnimationsEnabled() | |
UIView.setAnimationsEnabled(false) | |
self.window!.rootViewController = rootViewController | |
UIView.setAnimationsEnabled(oldState) | |
}, completion: { (finished: Bool) -> () in | |
if completion { | |
completion!() |
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
Removing CocoaPods from a project is possible, but not currently automated by the CLI. First thing, if the only issue you have is not being able to use an xcworkspace you can use CocoaPods with just xcodeprojs by using the --no-integrate flag which will produce the Pods.xcodeproj but not a workspace. Then you can add this xcodeproj as a subproject to your main xcodeproj. | |
If you really want to remove all CocoaPods integration you need to do a few things: | |
NOTE editing some of these things if done incorrectly could break your main project. I strongly encourage you to check your projects into source control just in case. Also these instructions are for CocoaPods version 0.28.0, they could change with new versions. | |
Delete the standalone files (Podfile Podfile.lock and your Pods directory) | |
Delete the generated xcworkspace | |
Open your xcodeproj file, delete the references to Pods.xcconfig and libPods.a (in the Frameworks group) | |
Under your Build Phases delete the Copy Pods Resources and Check Pods Ma |
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
- (UIImage *) resizableImageWithSize:(CGSize)size | |
{ | |
if( [self respondsToSelector:@selector(resizableImageWithCapInsets:)] ) | |
{ | |
return [self resizableImageWithCapInsets:UIEdgeInsetsMake(size.height, size.width, size.height, size.width)]; | |
} else { | |
return [self stretchableImageWithLeftCapWidth:size.width topCapHeight:size.height]; | |
} | |
} |
OlderNewer