Save NSObject into NSUserDefaults in one-line, auto class mapping

Overview

Akaibu

What is it ?

  • Archive any class in just ONE-LINE of code.
  • Automatically map class's properties under the hood.
  • Drop in replacement of NSObject
  • Swifty <3

Installation

Drag n drop the Akaibu.swift into your project directory. Enjoy ~

// By extending Akaibu, it inherits from NSObject and NSCoding automatically

class Model: Akaibu {
    //.....
}

tl;dr

That's all you need to know

model.saveWithKey(key) // archive to NSUserDefaults
// or
Akaibu.saveWithKey(model, key) // archive to NSUserDefaults


let model = Akaibu.loadWithKey(key) as? Model // load from NSUserDefaults

Clear saved objects

Akaibu.removeAll()

Why Akaibu ?

  • Easy to use and save tons of time
  • You don't want CoreData
  • You are sick of encodeWithCoder: and initWithCoder:

About Akaibu:

  • Akaibu is inspired by the japanese word 「アーカイブ」 , which means archive.
You might also like...
Shows the issue with swift using an ObjC class which has a property from a swift package.

SwiftObjCSwiftTest Shows the issue with swift using an ObjC class which has a property from a swift package. The Swift class (created as @objc derived

Classes-and-structures-in-swift - This source files show what is the difference between class and structure

This source files show what is the difference between class and structure You ca

Link - a macos application for keeping important and complicated urls in one place
Link - a macos application for keeping important and complicated urls in one place

Link Description Link is a macos application for keeping important and complicat

Escuela - A student-productivity app. Everything in one place
Escuela - A student-productivity app. Everything in one place

escuela a student productivity app Features Tasks Notes Calendar (coming soon) A

Wordle-solver - A little command line app for finding the answer to Wordle

A little command line app for finding the answer to Wordle puzzles, written in S

JSONHelper - ✌ Convert anything into anything in one operation; JSON data into class instances, hex strings into UIColor/NSColor, y/n strings to booleans, arrays and dictionaries of these; anything you can make sense of!

JSONHelper Convert anything into anything in one operation; hex strings into UIColor/NSColor, JSON strings into class instances, y/n strings to boolea

Easy JSON to NSObject mapping using Cocoa's key value coding (KVC)
Easy JSON to NSObject mapping using Cocoa's key value coding (KVC)

#Motis Object Mapping Easy JSON to NSObject mapping using Cocoa's key value coding (KVC) Motis is a user-friendly interface with Key Value Coding that

A simple class that wraps the process of saving or loading a struct or class into a single file

EZFile This is a simple class that wraps the process of saving or loading a stru

TwilioChat_iOS - Twilio iOS SDK Implementaion Chat one-one Chat One-Many (Group)

TwilioChat_iOS - Twilio iOS SDK Implementaion Chat one-one Chat One-Many (Group) - Add Participant - Remove Participant Send Attachment Image Android - iOS Tested iOS - iOS Tested iOS - Android Tested React to Message, Delete a Message Read, Delivered, Sent Delete a Conversation Unread Messages Filter

Auto Layout (and manual layout) in one line.
Auto Layout (and manual layout) in one line.

Auto Layout (and manual layout) in one line. Quick Look view.bb.centerX().below(view2).size(100) It’s equivalent to iOS 9 API: view.centerXAnchor.cons

Manage multi-domain url auto mapping ip address table.
Manage multi-domain url auto mapping ip address table.

Domainer Multi-domain mapper. This library provides manage multi-domain table. Features Manage multi-domain mapping main domain. Find best domain whic

Save-the-dot-project-swift - Save the dot project with swift
Save-the-dot-project-swift - Save the dot project with swift

Save the Dot Apple introduced UIViewPropertyAnimator for iOS 10. We can use this

Video mp4 record save display - How to Take , Save and Display a .mp4 Video

Technicalisto How to Take , Save and Display a .mp4 Video Add your design with v

Handy Combine extensions on NSObject, including Set<AnyCancellable>.
Handy Combine extensions on NSObject, including SetAnyCancellable.

Storable Description If you're using Combine, you've probably encountered the following code more than a few times. class Object: NSObject { var c

Handy RxSwift extensions on NSObject, including rx.disposeBag.
Handy RxSwift extensions on NSObject, including rx.disposeBag.

NSObject+Rx If you're using RxSwift, you've probably encountered the following code more than a few times. class MyObject: Whatever { let disposeBag

Setup your class structure in Xcode Interface Builder and save() in Parse Server.
Setup your class structure in Xcode Interface Builder and save() in Parse Server.

ISParseBind With ISParseBind you can save, update and query PFObjects using the power of Xcode Interface Builder resources. https://www.youtube.com/wa

Save all your Mac apps for later with one click 🖱️

Later videoplayback.mp4 Save all your Mac apps for later with one click 🖱️ Later is a Mac menu bar app that clears and restores your workspace with e

Simple CLI utility to save off an image from every webcam hooked into a mac

macOSCameraCapture Simple CLI utility to save off an image from every webcam connected to the macOS machine. This utility is meant for research and te

Util for generation RSA keys on your client and save to keychain or convert into Data 🔑 🔐

RSASwiftGenerator 🔑 🔐 To run the example project, clone the repo, and run pod install from the Example directory first. Requirements ⚠️ SWIFT 4 XCod

Comments
  • fallback on ios8

    fallback on ios8

    I try Akaibu in my project, get an error at

    if let data = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(obj) as? Akaibu {
       return data
    }
    

    and xcode replace the snippet like that

    if #available(iOS 9.0, *) {
         if let data = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(obj) as? Akaibu {
              return data
         }
    } else {
       // Fallback on earlier versions
    }
    

    I need to support ios8. is there a way fallback on ios8?

    opened by funkyLover 2
Owner
Roy Tang
React/TS · Rust · Hong Kong
Roy Tang
Modern Swift API for NSUserDefaults

SwiftyUserDefaults Modern Swift API for NSUserDefaults SwiftyUserDefaults makes user defaults enjoyable to use by combining expressive Swifty API with

Luke 4.7k Jan 9, 2023
TypedDefaults is a utility library to type-safely use NSUserDefaults.

TypedDefaults TypedDefaults is a utility library to type-safely use NSUserDefaults. Motivation The talk Keep Calm and Type Erase On by Gwendolyn Westo

Kazunobu Tasaka 110 Feb 6, 2022
📕A single value proxy for NSUserDefaults, with clean API.

OneStore A single value proxy for NSUserDefaults, with clean API. With OneStore… Create one proxy(an OneStore object) for each NSUserDefaults value. M

Muukii 27 May 12, 2022
A lightweight wrapper over UserDefaults/NSUserDefaults with an additional layer of AES-256 encryption

SecureDefaults for iOS, macOS Requirements • Usage • Installation • Contributing • Acknowledgments • Contributing • Author • License SecureDefaults is

Victor Peschenkov 216 Dec 22, 2022
Modern Swift API for NSUserDefaults

SwiftyUserDefaults Modern Swift API for NSUserDefaults SwiftyUserDefaults makes user defaults enjoyable to use by combining expressive Swifty API with

Luke 4.7k Jan 9, 2023
NSUserDefaults with Wings!

#Palau: NSUserDefaults with Wings! Features | Included Types | Installation | Validators and Defaults | Custom Types | DidSet Callback | ------- Featu

symentis GmbH 387 Jun 29, 2022
CRUD is an object-relational mapping (ORM) system for Swift 4+.

CRUD is an object-relational mapping (ORM) system for Swift 4+. CRUD takes Swift 4 Codable types and maps them to SQL database tables. CRUD can create tables based on Codable types and perform inserts and updates of objects in those tables. CRUD can also perform selects and joins of tables, all in a type-safe manner.

PerfectlySoft Inc. 61 Nov 18, 2022
CodableFiles - Save and load Codable objects from DocumentDirectory on iOS Devices.

Welcome to CodableFiles, a simple library that provides an easier way to save, load or delete Codable objects in Documents directory. It’s primarily a

Egzon Pllana 36 Dec 20, 2022
CodableCloudKit allows you to easily save and retrieve Codable objects to iCloud Database (CloudKit)

CodableCloudKit CodableCloudKit allows you to easily save and retrieve Codable objects to iCloud Database (CloudKit) Features ℹ️ Add CodableCloudKit f

Laurent Grondin 65 Oct 23, 2022
Auto scrollable multi platform header menu usually used in food delivery applications - SwiftUI & Combine

Auto scrollable header menu - SwiftUI & Combine Features Auto scrollable up menu while navigating the list up and down Navigate to any section from up

Igor 6 Aug 13, 2022