Why do we need to create frameworks? because it has three major purposes mentioned below and also you can share your code with your team, other developer or iOS community.
- Code encapsulation
- Code modularity
- Code reuse
Let’s create the iOS framework.
Now just give some meta-data about your framework like name, organization, identifier etc (I hope you’re already aware of it).
We’re good to go till now. Just add the files that you want to keep within your framework.
Build the framework project to make sure that you get build succeeded with no build warnings or errors.
Things that you need to take care.
- Make sure to check Copy items if needed, so that the files actually copy into the new project instead of just adding a reference. Frameworks need their own code, not references, to be independent.
- Double-check that each of the files has Target Membership in ThreeRingControl to make sure they appear in the final framework. You can see this in the File Inspector for each file.
- Double-check the access modifiers, while creating framework access modifiers plays very important roles.
- if you’re creating Swift framework make sure you’re extending classes from NSObject otherwise it won’t reflect once you will import the framework.
Thanks for reading.
SOLID principle is an acronym created by Robert C Martin also unknown as Uncle Bob. It represents five principles for OOPS.
Now the first thought that came to my mind is Why do we need this? Here is the answer, using these principles we can solve the problems of a bad architecture.
Fragility where A small change may break complete module it’s really very difficult to find this if you don’t have good test cases.
Immobility where A component is very hard to reuse in another project or we can say multiple places in the same project because of too many dependencies.
Rigidity where Single change requires lots of developer efforts because it affects several parts of the project.
Here I want to add principles will not turn a bad programmer into a good programmer you need a better judgment there. Principles have to apply with judgment and you must be smart enough to understand when to apply what.
I have also written one blog where they have mentioned one more acronym like SOLID and it’s STUPID. This may hurt your feeling but yes if you are following this you are writing stupid code.
Thank you for reading the quick introduction, In next blogs, I will try to define all principles with Swift Code.
How to Respond to an Authentication Challenge
If a session requires authentication it creates authentication challenge
in order for the connection to continue, the delegate has three options.
- Provide authentication credentials
- Attempt to continue without credentails
- Cancel the authentication request.
NSURLProtectionSpace will give all information about the authentication type and failure if any attempts failed earlier.
To attempt to authenticate, the application should create an NSURLCredential object with authentication information of the form expected by the server. You can determine the server’s authentication method by calling authenticationMethod on the protection space.
- HTTP basic authentication (NSURLAuthenticationMethodHTTPBasic) requires a user name and password. P
- HTTP digest authentication (NSURLAuthenticationMethodHTTPDigest), like basic authentication, requires a user name and password.withcredentialWithUser:password:persistence:.
- Client certificate authentication (NSURLAuthenticationMethodClientCertificate) requires the system identity and all certificates needed to authenticate with the server. Create an NSURLCredential object.
- Server trust authentication (NSURLAuthenticationMethodServerTrust) requires a trust provided by the protection space of the authentication challenge.
Continuing Without Credentials
If the delegate chooses not to provide a credential for the authentication challenge, it can attempt to continue without one.
• NSURLSessionAuthChallengePerformDefaultHandling processes the request as though the delegate did not provide a delegate method to handle the challenge.
- NSURLSessionAuthChallengeRejectProtectionSpace rejects the challenge. Depending on the authentication types allowed by the server’s response, the URL loading class may call this delegate method more than once, for additional protection spaces.
Canceling the Connection
The delegate may also choose to cancel the authentication challenge, by passing NSURLSessionAuthChallengeCancelAuthenticationChallenge to the provided completion handler block.
Serverless architecture, refer to the application that significantly depends on third party services or custom code that’s run with in ephemeral containers, AWS Lambda is the best-known example.
As the name suggests it not like that code is running without servers, here the code written in traditional server style such as micro services so pricing the based on the actual amount of resources consumed by application rather than on pre-purchased units of capacity.
Cost, effective because it not like renting or purchasing fixed quality of servers even it’s more cost effective than provisioning an autoscaling group.
Operations, as developers and operators do not need to spend time for setting up and tuning auto scaling policies.
Productivity, the units of code exposed to the outside world are simple functions. means programmer does not need to worry about multithreading or HTTP directly requests.
Performance, Infrequently used serverless code may suffer from greater response latency than a dedicated server.
Monitoring and debugging, diagnosing performance or resource usage problem may be more difficult here, attaching profilers or debuggers little difficult. furthermore, the environment in which the code runs is typically not open source so its performance characteristics cannot be precisely replicated in the local environment.
AWS Lambda, Azure functions with node.js, Kubernetes etc.