macOS Sqlite tableView 샘플 - objective c

Overview

목적

  • Objective C언어를 이용하여 macOS를 개발해본다.
  • Sqlite를 이용하여 데이터를 저장하고, 불러와본다.
    • FMDB를 이용한다.
  • 데이터를 NSTableView를 이용하여 불러와본다.
    • 추가적으로 NSOutlineView 구현해본다.
  • 추가적으로 KVOController를 이용하여 KVO를 사용해본다.

Pod

  • FMDB
  • KVOController

FMDB

  • 1.DB저장소 위치 설정
  • 2.DB open
  • 3.Table 생성 및 insert
  • 4.select
    • FMResultSet 를 반환하므로, next를 이용하여 원하는 컬럼을 가져와 타입으로 만들어주는 과정이 필요하다.
    FMResultSet *result = [self.sqldb selectChatRoom];
    self.chatRoom = [[NSMutableArray alloc] init];
    while ([result next]) {
        ChatRoom *chatRoom = [[ChatRoom alloc] init];
        chatRoom.chatRoomChat = [result stringForColumn:@"chatRoomChat"];
        chatRoom.chatRoomTitle = [result stringForColumn:@"chatRoomTitle"];
        chatRoom.chatRoomId = [result intForColumn:@"chatRoomId"];
        [self.chatRoom addObject:chatRoom];
    }

궁금증

  • Pod으로 설치했더니, FMDB의 macOS 타겟이 10.6, KVOController은 10.7로 되어있는데, 그럼 지금 프로젝트는 최소타겟이 10.12인데 괜찮겠지...? ?

  • FMDB를 이용하여 SQlite 저장소 가져오는 객체를 SQLDB 객체로 만들었고, 이 과정에서 싱글톤으로 구현했다. 여기서 싱글톤으로 구현하기 위해, GCD를 이용했는데, dispatch_oncestatic에 대해서 공부하자.

+ (SQLDB *) shared {
    static SQLDB *instance = nil;
    static dispatch_once_t pred;
    
    dispatch_once(&pred, ^{
        instance = [[SQLDB alloc] init];
    });
    return instance;
}
You might also like...
Easy and beautiful way for a user to pick content, files or images. Written in Objective C
Easy and beautiful way for a user to pick content, files or images. Written in Objective C

##JVTImageFilePicker Description ImageFilesPicker Is a butifuly designed UICompenent for uploading content Preview from recent camera roll Live Camera

Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS
Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS

简体中文 DefaultsKit leverages Swift 4's powerful Codable capabilities to provide a Simple and Strongly Typed wrapper on top of UserDefaults. It uses less

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.

中文版本请参看这里 MMKV is an efficient, small, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on Andr

macOS WeChat.app header files version history (automatic updated)

macos-wechat-app-tracker macOS WeChat.app header files version history (automatic updated) Troubleshooting $ class-dump -H /Applications/WeChat.app 20

Natural - A macOS quick link finder
Natural - A macOS quick link finder

natural a macOS quick link finder just a fun side project based on uiw.tf – chec

MySQL driver for Swift 3 (macOS and Linux)

MySQL MySQL Usage // do your magic Installation import PackageDescription let package = Package( dependencies: [ .Package(url: "https://g

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

A external macos application to generate and execute tuist commands
A external macos application to generate and execute tuist commands

Tuist Menu Bar App An external macos application to generate and execute tuist commands. How it works? Parses all tasks and their arguments with the -

macOS App for App Store Connect to Improve Processing Efficiency and Enjoy the Party.
macOS App for App Store Connect to Improve Processing Efficiency and Enjoy the Party.

Apple Party(苹果派) 一、App 介绍 AppleParty 是三七互娱旗下37手游 iOS 团队研发,实现快速操作 App Store Connect 后台的自动化 macOS 工具。 使用和原理介绍:开源一款苹果 macOS 工具 - AppleParty(苹果派) 支持功能 内购买

Owner
HyunSu Park
HyunSu Park
A Cocoa / Objective-C wrapper around SQLite

FMDB v2.7 This is an Objective-C wrapper around SQLite. The FMDB Mailing List: https://groups.google.com/group/fmdb Read the SQLite FAQ: https://www.s

August 13.7k Sep 21, 2022
SQLite.swift - A type-safe, Swift-language layer over SQLite3.

SQLite.swift provides compile-time confidence in SQL statement syntax and intent.

Stephen Celis 8.5k Sep 24, 2022
A toolkit for SQLite databases, with a focus on application development

A toolkit for SQLite databases, with a focus on application development

Gwendal Roué 5.4k Sep 20, 2022
Realm is a mobile database: a replacement for Core Data & SQLite

Realm is a mobile database that runs directly inside phones, tablets or wearables. This repository holds the source code for the iOS, macOS, tvOS & wa

Realm 15.5k Sep 17, 2022
Implement Student Admission System using SQlite

StudentAdmissionSQLiteApp Implement Student Admission System using SQlite. #Func

Hardik 2 Apr 27, 2022
BucketServer - Small API with SQLite database that saves notes for an iOS appliction called Bucket list

BucketList Server-Side Small API with SQLite database that saves notes for an iO

null 0 Dec 30, 2021
A Swift wrapper for SQLite databases

Squeal, a Swift interface to SQLite Squeal provides access to SQLite databases in Swift. Its goal is to provide a simple and straight-forward base API

Christian Niles 297 Aug 6, 2022
A stand-alone Swift wrapper around the SQLite 3 client library.

Perfect - SQLite Connector This project provides a Swift wrapper around the SQLite 3 library. This package builds with Swift Package Manager and is pa

PerfectlySoft Inc. 45 Apr 4, 2022
MagicData - A replacement of SQlite, CoreData or Realm.

MagicData A replacement of SQlite, CoreData or Realm. It is very easy to use and is a light version. Guides MagicData We use MagicData manage all the

Underthestars-zhy 20 Jul 4, 2022
An Objective-C wrapper for RocksDB - A Persistent Key-Value Store for Flash and RAM Storage.

ObjectiveRocks ObjectiveRocks is an Objective-C wrapper of Facebook's RocksDB - A Persistent Key-Value Store for Flash and RAM Storage. Current RocksD

Iskandar Abudiab 55 Jun 15, 2022