42 lines
1.2 KiB
Markdown
42 lines
1.2 KiB
Markdown
# MusicBrainz Swift
|
|
|
|
Documentation and reference for the MusicBrainz API implementation.
|
|
|
|
## Search API Reference
|
|
- [MusicBrainz Search API Documentation](https://musicbrainz.org/doc/MusicBrainz_API/Search)
|
|
|
|
## SwiftUI and SwiftData Readiness
|
|
|
|
The library is designed to be cross-platform and modern-Swift ready.
|
|
|
|
### SwiftUI
|
|
All models conform to `Identifiable`, `Hashable`, and `Equatable`. This makes them perfect for:
|
|
- Efficient list rendering using `ForEach`.
|
|
- State management with `@State` or `@Observable`.
|
|
- Value-based equality checks.
|
|
|
|
### SwiftData Bridging
|
|
Since this library is cross-platform, it does not import `SwiftData` directly. To persist MusicBrainz entities in SwiftData, you should create separate `@Model` classes and bridge them.
|
|
|
|
**Example:**
|
|
|
|
```swift
|
|
import SwiftData
|
|
import MusicBrainz
|
|
|
|
@Model
|
|
class PersistentArtist {
|
|
@Attribute(.unique) var id: String
|
|
var name: String
|
|
var country: String?
|
|
|
|
init(from artist: MusicBrainz.Artist) {
|
|
self.id = artist.id
|
|
self.name = artist.name
|
|
self.country = artist.country
|
|
}
|
|
}
|
|
```
|
|
|
|
Bridging DTOs to local storage models ensures that your persistence layer remains decoupled from the network layer, which is a best practice.
|