Catatan Seekor Swift

Swift adalah bahasa pemrograman yang dikembangkan oleh Apple untuk iOS, macOS, watchOS, dan tvOS development.

Fundamental

Variables & Constants

// Variables
var mutableVariable = "Can be changed"
var explicitType: String = "Explicit type declaration"

// Constants
let constantValue = "Cannot be changed"
let explicitConstant: Int = 42

Data Types

// Basic Types
let string: String = "Hello"
let integer: Int = 42
let double: Double = 3.14
let boolean: Bool = true

// Optional Types
var optionalString: String? = "Optional value"
var nilString: String? = nil

Control Flow

Functions

Classes & Structures

References

Stack Overflow

Articles

Tools

Xcode

  • Official IDE untuk development iOS/macOS

  • Integrated debugging dan testing

  • Interface Builder untuk UI design

Swift Package Manager

  • Dependency management

  • Package distribution

  • Build system integration

CocoaPods

  • Third-party library management

  • Dependency resolution

  • Easy integration

Best Practices

Naming Conventions

  • Use camelCase untuk variables dan functions

  • Use PascalCase untuk types

  • Be descriptive dengan naming

Error Handling

Memory Management

  • Use weak references untuk avoid retain cycles

  • Use unowned references carefully

  • ARC handles most memory management automatically

Last updated