Filters

Hide filters
Platform
Content Type
Difficulty

All Tutorials · 12 Results

Contained in: Expert Swift objective c
iOS & Swift

Chapter in Expert Swift

Objective-C Interoperability

Like it or not, Objective-C is still a heavily used language in legacy codebases and apps that have been in production for many years. In your own apps, you’ll often have a sizable Objective-C codebase that just doesn’t feel at home inside your Swift code…
iOS & Swift

Chapter in Expert Swift

Strings

…have canonical equivalence. Swift equality checks the canonical equivalence of the content and not the absolute equality of the content. Try the same with Objective-C types: let eAcute_objC: NSString = "\u{E9}" let combinedEAcute_objC: NSString = "\u{65}\u{301}" eAcute_objC.length // 1 combinedEAcute_objC.length // 2 eAcute_objC == combinedEAcute_objC // false…
iOS & Swift

Chapter in Expert Swift

API Design Tips & Tricks

…into Xcode is the ability to view the generated interface of source files. You used this a bit earlier in this book, in the “Objective-C Interoperability” chapter, but you can use the same capability for Swift files, too. If you put the following code in a Swift file: import…
iOS & Swift

Chapter in Expert Swift

Introduction

…summer of 2014 at Apple’s Worldwide Developer Conference (WWDC). It was real in that, out of the box, it had full interoperability with Objective-C and could leverage battle-tested frameworks such as UIKit for building apps. The iOS community embraced it quickly and wholeheartedly, with little exception…
iOS & Swift

Chapter in Expert Swift

Instrumentation

…just represented differently. The Debug Memory Graph analyzes a snapshot of your app’s memory, regardless of whether the app was built in Swift, Objective-C or even C. But the graph can identify if the reference found was weak or strong. In the scenario you’re debugging, the memory…
iOS & Swift

Chapter in Expert Swift

Numerics and Ranges

…radix 10 type that can handle this, it’s not yet natively implemented for Swift. However, Swift provides Decimal, an overlay (wrapper type) on Objective-C’s NSDecimalNumber. Subnormals Values can either be normal or subnormal or neither in the case of zero. A normal number uses the leading…
iOS & Swift

Chapter in Expert Swift

Types & Mutation

…anywhere, this satisfies the definition for value semantics. Functional languages often use strict immutability at the cost of performance to achieve value semantics. Note: Objective-C uses a type-level mutation model. For example, NSString is immutable. But NSMutableString, which derives from NSString, adds mutability. However, if you have…
iOS & Swift

Chapter in Expert Swift

Protocols

This instance method may or may not exist in the class — maybe you forgot to write it. In a more dynamic language such as Objective-C, the compiler will happily run the code and nothing will happen. Some dynamic languages, such as JavaScript, will run the code but show…
iOS & Swift

Chapter in Expert Swift

Introduction

…charge your Swift powers, and use all of what Swift has to offer. We’ll cover topics like Higher order functions, Functional reactive programming, Objective-C interoperability, using Instrumentation, and API design…
iOS & Swift

Chapter in Expert Swift

Unsafe

…newly bound pointer outside this closure. Doing either will cause undefined behaviors. For the next example, consider having a C++ API that initializes memory with two different objects and returns them as a raw pointer. A Swift imitation for this API would look like this: func initRawAB() -> UnsafeMutableRawPointer…
iOS & Swift

Chapter in Expert Swift

Higher-Order Functions

…equivalents, you can either create a closure and call word() on each object or restructure Int.word to match the signature requirements for map(_:). In the same playground, create a new version of flip: func flip<A, C>( _ originalMethod: @escaping (A) -> () -> C ) -> () -> (A) -> C…
iOS & Swift

Chapter in Expert Swift

Codable

…they don’t work on a single property of your original response. You’ll want to decode each value as needed and construct these objects by hand to achieve the wanted result. Start by adding the following two properties to Card: let set: Set let attributes: Attributes? Next…