Posts

Showing posts with the label iPhone

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...

Optional Chaining

Apple says "Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil" . While processing if optional has value then the process will succeed otherwise the process will return nil . This querying, calling properties, methods and subscribe can be chained together and it failed gracefully if chain returns nil . An Alternative to Forced unwrapping: you will add question mark '?' after the optional value on which property you will wish to call properties, method, and subscripts if the optional is non- nil . Could an important interview question - The main difference between optional chaining and forced unwrapping is optional chaining fails gracefully whereas forced unwrapping will give runtime error when the optional value is nil . The result of optional chaining will return the same type value but that value will be wrapped with optional. So if Int is return t...

Swift Optional

Some people found it very confusing initially but when you will understand then it is simple. As we know optional tells itself about it. It's two cases. The first case when a value can be present for a type, then we need to unwrap if need to use it. Second case when a value can not be present for a type. We use '?' to mark a value as optional. class Student {     var name: String ? //  name becomes optional } When you declare the name string as optional by marking ' ? ' then it's valued automatically is set to nil.  NOTE: Swift 'nil' is not same as objective c 'nil'. In Objective-C, it is a pointer to an object which does not exist whereas in swift it's just an absence of a value for a type. let person = Student() print( person .name) When you access the name it will print a  nil . As there is no value assigned to name. Once we will provide a value to name, let say, "Swift". Then it looks like....

What's New in iOS 11.0

As Y'all know #WWDC17 already started. So here you can find new dishes !! in your dev plate. Few dishes like ARkit, Musickit and etc. You will loveit. I am just writing main points below for more details please check the release notes link in the bottom of the page. ********* General  ********* New - Support for binary (non-text) barcodes. Added API To: AV Foundation Core Image Sirikit  Support detection, decoding and creating barcodes with binary content Added  CIBarcodeDescriptor , a new barcode descriptor object to Core Image to provide interoperability with AV Foundation and the Vision APIs. ********* ********* New - MusicKit. ********* ********* MusicKit gives your app access to the full Apple Music catalog, and to the user’s library. MusicKit gives your app access to the full Apple Music catalog, and to the user’s library. Added and updated functionality in StoreKit for retrieving client tokens and storefront identifiers. Add...

Copy Vs Mutable Copy in iOS

It's found very confusing for most of the folks, who is not having much experience in Objective-C. Before starting I just to say: Just remember below lines- 1 - copy always creates an immutable copy means you can not modify the object. 2 - mutableCopy always creates a mutable copy  means you can modify the object Here onwards I try to explain copy and mutable copy with some examples: copy: NSArray *obj = [ NSArray arrayWithObjects : @"1" , @"2" , nil ]; NSArray *copyObj = [obj copy ]; NSArray *mutableObj = [obj mutableCopy ]; When you try to see the details of copyObj its clearly shows  __NSArrayI which tells that you can not modify this object Printing description of copyObjy: ( 1, 2 ) Same way  When you try to see the details of mutableObj its clearly shows  __NSArrayM which tells that you can modify this object Printing description of mutableObjy: ( 1, 2 ) As the copyObj is ass...