Posts

Showing posts with the label iPad

Closures in Swift - Part 2

Image
 As we discussed the closure in detail in the previous blog as Closure in Swift - Part 1 . I would like to suggest to go first if you want to understand this better.  Closures as Reference Types: As if we assign as  let closure =  closreReturnFromFunction()   to constant but that does not mean that its constant and closure scope can not be changed. As you have seen in the previous  Closure in Swift - Part 1 .  that counter can be modified once the closure will execute, this is because closure is reference types.   When we assigned closure to variable or constant we actually assigned closure reference not the content of closure. I Hope, it's clear !!. Escaping Closures: A closure is said to be escaping closure when it is passed as a function argument to the function and it will execute after the function returns from its scope. This is asynchronous in behavior.   Let's understand what that does It means. It's simple. Trust me. So...

Xcode 11 New Features

New Features General Xcode 11 beta supports development with SwiftUI, available when running on macOS 10.15 beta. Xcode supports uploading apps from the Organizer window or from the command line with xcodebuild or xcrun altool . Application Loader is no longer included with Xcode. LaunchServices on macOS now respects the selected Xcode when launching Instruments, Simulator, and other developer tools embedded within Xcode. Apple Clang Compiler:  Deprecation warnings will be issued when standard library facilities that were deprecated in the active Standard version are used.  Asset Catalog Assets can now be cut, copied, pasted, and duplicated using the menu or keyboard shortcuts. Build System Xcode removes some entries from the Info.plist file of a product at build time if the entries are not appropriate for the platform being built for, which is useful for targets which are configured to build for multiple platforms. This behavior can be disabled ...

Closures in Swift - Part 1

Closures: Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.  Closures can capture and store references to any constants and variables from the context in which they are defined .  Swift handles all of the memory management of capturing for you. Declaration: You can declare as below: { ( parameters ) -> return type in statements } The  parameters  in closure expression syntax can be in-out parameters, but they can’t have a default value.  A simple closure can be declared as below as well let  newClosures = {      print ( "This is new basic closure which very simple to create and call" ) } we can call using like this  newClosures (). Closure With Parameter:  we passed the parameter in the closure and can pass the string as below. The basic different closure and function is closure do not u...

Swift: Type Casting

Image
Type Casting: Using type casting you will get to know about the type of an instance and at the same time, you can treat as a different super class or subclass hierarchy from its own class hierarchy. We use two different operators to do type casting. as is It can be checked for protocol conformance as well. we will see with an example:      we created an array of with objects which can have Movie and Song object. However, if you iterate over the contents of this array, the items you receive back are typed as  MediaItem , and not as  Movie  or  Song . Checked the below image and if you need to use contents of the array then you have type cast or downcast in a different type. Checking Type: Use the  type check operator  ( is ) to check whether an instance is of a certain subclass type.  The type check operator returns  true  if the instance is of that subclass type and  fal...