LeitnerSwift is a simple Swift package that implements the Leitner System, a popular algorithm used to aid in spaced repetition for efficient memorization. It manages cards and boxes to ensure that items you struggle with are reviewed more frequently than those you remember easily.
- Customizable Boxes: Specify the number of boxes in your system.
- Card Management: Add, update, and review cards as part of the spaced repetition learning system.
- Flexible Review Scheduling: The package automatically handles scheduling card reviews based on the box's intervals.
To use LeitnerSwift in your project, you can add it as a dependency using Swift Package Manager.
- Open your project in Xcode.
- Go to
File > Add Packages.... - Paste the following URL into the search bar:
https://github.com/mfsaglam/LeitnerSwift
-
Select the version you want to use.
-
Click
Add Package.
Alternatively, you can add it to your Package.swift file:
dependencies: [
.package(url: "https://github.com/mfsaglam/LeitnerSwift.git", from: "1.3.7")
]You can initialize a LeitnerSystem with a specific number of boxes. The system will automatically generate review intervals according to the Leitner algorithm.
import LeitnerSwift
// Create a Leitner system with 5 boxes
let leitnerSystem = LeitnerSystem(boxAmount: 5)You can add cards to the system. Cards start in the first box.
let card = Card(id: UUID(), question: "What is the capital of France?", answer: "Paris")
leitnerSystem.addCard(card)After a review session, you can update the card's progress. If the user answers correctly, the card will move to the next box. If not, the card will return to the first box.
try leitnerSystem.updateCard(card, correct: true)You can fetch cards that are due for review. The method returns cards whose next review date is today or earlier.
let dueCards = try leitnerSystem.dueForReview(limit: 10)You can also load pre-existing boxes into the system, which is useful for saving and restoring state from persistent storage.
leitnerSystem.loadBoxes(boxes: existingBoxes)Contributions are welcome! Feel free to open an issue or submit a pull request.
LeitnerSwift is licensed under the MIT License. See the LICENSE file for more details.