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
UIView.animateKeyframesWithDuration(0.6, delay: 0.0, options: UIViewKeyframeAnimationOptions.CalculationModeLinear, animations: { | |
UIView.setAnimationRepeatCount(3); | |
self.myconstraint.constant = 40 | |
UIView.addKeyframeWithRelativeStartTime(0.0, relativeDuration: 0.3, animations: { | |
self.view.layoutIfNeeded() | |
}) | |
self.myconstraint.constant = 30 | |
UIView.addKeyframeWithRelativeStartTime(0.3, relativeDuration: 0.3, animations: { |
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
Problem: | |
Xcode does not create warnings when API introduced after "Deployment Target SDK Version" are used in the source code. | |
Some background information: | |
The APIs that are introduced after the deployment target version are weak imported by the llvm clang compiler in the binary to manage backward compatibility i.e, target device will run the new weak imported API if it is available (Think how you will access a weak variable in swift). | |
Hence if proper care is not taken, app will break at runtime. | |
In iOS and Mac OSX SDKs API availabilities are marked with a macro(ex:NS_AVAILABLE_IOS) defined in runtime header(NSObjRuntime.h) file. |
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
Cocoapods | |
Jargons: | |
• Cocoapods | |
o It is a tool written in ruby to help with your pods | |
• Pod | |
o Pod is a simple ruby file to specify project dependencies. |
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
Design patterns | |
Behavioural: Deals with communication of objects | |
Chain-Of-Responsibility - Think of UIResponder class | |
Command pattern - NSInvocation class. Support undoable operations | |
Interpreter - language parsing. Think of expression evaluation | |
Iterator - NSEnumerator; A unified interface for interating a collection. | |
Mediator - Think of a translator's role in multi lingual people communication. | |
Memento - Think of a storing in the middle of a game and restore it. | |
observer - KVO. |
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
For a background download service with NSURLSession | |
1. Create a download task with background session configuration with NSURLSession delegates. | |
2. If, application is in foreground NSURLsession delegate will be called directly. | |
3. If application is background or killed additional methods are needed in the app delegate . | |
4. "handleEventsForBackgroundURLSession" will be called first, where it is necessary to reinstate the session object with the delegate again. Otherwise delegate methods will not be called. | |
5. "URLSessionDidFinishEventsForBackgroundURLSession" will be called once everything is done. You can decide what you want to do once the download is complete like updating the UI. |
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 UIKit | |
class ViewController: UIViewController { | |
/*** | |
* | |
* This method explains a GCD based synchronization mechanism to protect a shared resource. | |
* In objective C - @synchronized(Object) directive on a object provides similar protection. | |
* Only one thread can enter a synchronized section on the object being locked. |