# Catatan Seekor Swift

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

## Fundamental

### Variables & Constants

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

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

### Data Types

```swift
// 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

```swift
// If statements
if condition {
    // code
} else if anotherCondition {
    // code
} else {
    // code
}

// Switch statements
switch value {
case 1:
    print("One")
case 2:
    print("Two")
default:
    print("Other")
}
```

### Functions

```swift
// Basic function
func greet(name: String) -> String {
    return "Hello, \(name)!"
}

// Function with multiple parameters
func calculate(a: Int, b: Int) -> Int {
    return a + b
}
```

### Classes & Structures

```swift
class Person {
    var name: String
    var age: Int
    
    init(name: String, age: Int) {
        self.name = name
        self.age = age
    }
    
    func introduce() {
        print("Hi, I'm \(name) and I'm \(age) years old")
    }
}
```

## References

### Stack Overflow

* [How can I get key's value from dictionary in Swift?](https://stackoverflow.com/questions/25741114/how-can-i-get-keys-value-from-dictionary-in-swift)

### Articles

* [JSON Parsing in Swift explained with code examples](https://www.avanderlee.com/swift/json-parsing-decoding/)
* [Let's Set Up Your iOS Environments](https://thoughtbot.com/blog/let-s-setup-your-ios-environments)
* [Managing different Environments using XCode Build Schemes and Configurations](https://medium.com/flawless-app-stories/managing-different-environments-using-xcode-build-schemes-and-configurations-af7c43f5be19)

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

```swift
do {
    let result = try someFunction()
} catch {
    print("Error: \(error)")
}
```

### Memory Management

* Use weak references untuk avoid retain cycles
* Use unowned references carefully
* ARC handles most memory management automatically
