Tworzenie zaawansowanych aplikacji w środowisku ios. Wykład 7. Saving data in ios

Podobne dokumenty
Zmiany techniczne wprowadzone w wersji Comarch ERP Altum

Zarządzanie sieciami telekomunikacyjnymi

OpenPoland.net API Documentation

Testy jednostkowe - zastosowanie oprogramowania JUNIT 4.0 Zofia Kruczkiewicz

POLITYKA PRYWATNOŚCI / PRIVACY POLICY

EaglePCB_2_FreeCAD (beta)

Zakopane, plan miasta: Skala ok. 1: = City map (Polish Edition)

Instrukcja obsługi User s manual

Helena Boguta, klasa 8W, rok szkolny 2018/2019

Rev Źródło:

Rozpoznawanie twarzy metodą PCA Michał Bereta 1. Testowanie statystycznej istotności różnic między jakością klasyfikatorów

1. CZYM JEST SERIALIZACJA

SubVersion. Piotr Mikulski. SubVersion. P. Mikulski. Co to jest subversion? Zalety SubVersion. Wady SubVersion. Inne różnice SubVersion i CVS

Camspot 4.4 Camspot 4.5

Instrukcja konfiguracji usługi Wirtualnej Sieci Prywatnej w systemie Mac OSX

MS Visual Studio 2005 Team Suite - Performance Tool

Zarządzanie sieciami komputerowymi - wprowadzenie

Bardzo formalny, odbiorca posiada specjalny tytuł, który jest używany zamiast nazwiska

Website review radcowie.biz

ARNOLD. EDUKACJA KULTURYSTY (POLSKA WERSJA JEZYKOWA) BY DOUGLAS KENT HALL

USB firmware changing guide. Zmiana oprogramowania za przy użyciu połączenia USB. Changelog / Lista Zmian


Arrays -II. Arrays. Outline ECE Cal Poly Pomona Electrical & Computer Engineering. Introduction

Installation of EuroCert software for qualified electronic signature

Stargard Szczecinski i okolice (Polish Edition)

Website review auto-web.pl

FORMULARZ REKLAMACJI Complaint Form

Surname. Other Names. For Examiner s Use Centre Number. Candidate Number. Candidate Signature

Wojewodztwo Koszalinskie: Obiekty i walory krajoznawcze (Inwentaryzacja krajoznawcza Polski) (Polish Edition)

Raport bieżący: 44/2018 Data: g. 21:03 Skrócona nazwa emitenta: SERINUS ENERGY plc

User s manual for icarwash

Website review pureorganic.pl

Wprowadzenie do psql i SQL. Język komend psql. Podstawy instrukcji SELECT

Dynamiczny DNS dla usług typu Neostrada przykład konfiguracji

INSTRUKCJE JAK AKTYWOWAĆ SWOJE KONTO PAYLUTION

General Certificate of Education Ordinary Level ADDITIONAL MATHEMATICS 4037/12

1945 (96,1%) backlinks currently link back (74,4%) links bear full SEO value. 0 links are set up using embedded object

Tychy, plan miasta: Skala 1: (Polish Edition)

Tworzenie zaawansowanych aplikacji w środowisku ios. Wykład 2 Objective-C. Tomasz Idzi

Domy inaczej pomyślane A different type of housing CEZARY SANKOWSKI

EXCEL PL PROGRAMOWANIE PDF

Machine Learning for Data Science (CS4786) Lecture11. Random Projections & Canonical Correlation Analysis

Wprowadzenie do BD Operacje na bazie i tabelach Co poza zapytaniami? Algebra relacji. Bazy Danych i Systemy informacyjne Wykład 2.

Wyjątki. try - except

Weronika Mysliwiec, klasa 8W, rok szkolny 2018/2019

EXAMPLES of file operations using the library <stdio.h>


Zasady rejestracji i instrukcja zarządzania kontem użytkownika portalu

ZARZADZANIE RYZYKIEM WALUTOWYM PDF

Healthix Consent Web-Service Specification

Revenue Maximization. Sept. 25, 2018

SEO Audit for domain zdrowewidzenie.pl

Karpacz, plan miasta 1:10 000: Panorama Karkonoszy, mapa szlakow turystycznych (Polish Edition)

Wojewodztwo Koszalinskie: Obiekty i walory krajoznawcze (Inwentaryzacja krajoznawcza Polski) (Polish Edition)

SEO Audit for domain blog.rabinek.pl

The HOCHTIEF Polska Supplier Portal Frequently Asked Questions (FAQ)

ANKIETA ŚWIAT BAJEK MOJEGO DZIECKA

PLSH1 (JUN14PLSH101) General Certificate of Education Advanced Subsidiary Examination June Reading and Writing TOTAL

Wykład 5_2 Arkusze stylów dziedziczenie. Technologie internetowe Zofia Kruczkiewicz

Office 365 Midsize Business

Katowice, plan miasta: Skala 1: = City map = Stadtplan (Polish Edition)

HAPPY ANIMALS L01 HAPPY ANIMALS L03 HAPPY ANIMALS L05 HAPPY ANIMALS L07

HAPPY ANIMALS L02 HAPPY ANIMALS L04 HAPPY ANIMALS L06 HAPPY ANIMALS L08

MaPlan Sp. z O.O. Click here if your download doesn"t start automatically

USB firmware changing guide. Zmiana oprogramowania za przy użyciu połączenia USB. Changelog / Lista Zmian

Kurs programowania. Wykład 13. Wojciech Macyna. 14 czerwiec 2017

(Apache) CouchDB. Krzysztof Kulewski 2008

SSO Management API configuration

How to Connect a Siretta Industrial Router to a VPN Tunnel Using OpenVPN Protocol

HISZPANSKI NA POZIOMIE PDF

klikamy Next 4. Wybieramy zgodność z systemem Virtual Machine hardware compatibility z listy zaznaczamy Workstation 6 Next 5.

Emilka szuka swojej gwiazdy / Emily Climbs (Emily, #2)

UMOWY WYPOŻYCZENIA KOMENTARZ

y = The Chain Rule Show all work. No calculator unless otherwise stated. If asked to Explain your answer, write in complete sentences.

Polska Szkoła Weekendowa, Arklow, Co. Wicklow KWESTIONRIUSZ OSOBOWY DZIECKA CHILD RECORD FORM

Rys. 1.Okno główne serwera Cisco TFTP Server. Rys.2.Okno opcji serwera Cisco TFTP Server

Programowanie Komputerów

SQL 4 Structured Query Lenguage

Marzena Kanclerz. Microsoft Channel Executive. Zachowanie ciągłości procesów biznesowych. z Windows Server 2012R2

NoSQL Not Only SQL, CouchDB. I.Wojnicki, NoSQL. Apache CouchDB has started. Time to relax. Igor Wojnicki

Polski Krok Po Kroku: Tablice Gramatyczne (Polish Edition) By Anna Stelmach

Pobieranie argumentów wiersza polecenia

archivist: Managing Data Analysis Results

Intro. I.Wojnicki, ZTB:XML ZTB: XML. Igor Wojnicki. Katedra Informatyki Stosowanej, Akademia Górniczo-Hutnicza w Krakowie.

MeetingHelper. Aplikacja Android ułatwiająca przekazywanie materiałów pomiędzy uczestnikami spotkania. Instrukcja obsługi dla programisty

tradycyjna normalny multicache bardzo du y mobilna

Formularz recenzji magazynu. Journal of Corporate Responsibility and Leadership Review Form

DODATKOWE ĆWICZENIA EGZAMINACYJNE

Logika rozmyta typu 2

U3000/U3100 Mini (Dla Komputera Eee na systemie operacyjnym Linux) Krótka Instrukcja

Machine Learning for Data Science (CS4786) Lecture 11. Spectral Embedding + Clustering

XML. 6.6 XPath. XPath is a syntax used for selecting parts of an XML document

Oferta przetargu. Poland Tender. Nazwa. Miejscowość. Warszawa Numer ogłoszenia. Data zamieszczenia Typ ogłoszenia

TTIC 31210: Advanced Natural Language Processing. Kevin Gimpel Spring Lecture 8: Structured PredicCon 2

w PL/SQL bloki nazwane to: funkcje, procedury, pakiety, wyzwalacze

X11R5. .Xresources. Pliki konfiguracyjne X-Windows. Zasada działania X11. .xinitrc. X protocol X server. X client. X library

USB firmware changing guide. Zmiana oprogramowania za przy użyciu połączenia USB. Changelog / Lista Zmian

Realizacja systemów wbudowanych (embeded systems) w strukturach PSoC (Programmable System on Chip)

Przechowywanie danych w IOS

Systemy wbudowane. Poziomy abstrakcji projektowania systemów HW/SW. Wykład 9: SystemC modelowanie na różnych poziomach abstrakcji

Transkrypt:

Tworzenie zaawansowanych aplikacji w środowisku ios Wykład 7 Saving data in ios

Agenda NSString and NSData NSFileManager Property List JSON Core Data

ios Directories App Documents Inbox Library Caches temp

ios Directories Directory Description Backed up by itunes AppName.app This directory contains the app and all of its resources. NO Documents/ Use this directory to store user-generated content. YES Documents/Inbox Use this directory to access files that your app was asked to open by outside entities. Such as mail s attachments. YES Library This is the top-level directory for any files that are not user data files. YES Library/Caches Subfolder of Library for any caching files. NO Tmp/ Use this directory to write temporary files that don t need to persist between launches of your app. NO

Accessing File Paths NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *docpath = [paths firstobject]; NSString *path = [docpath stringbyappendingcomponent:@ myfile.txt ];

Writing NSData BOOL success = [data writetofile:path options:nsdatawritingatomic error:&error]; NSDataWritingAtomic - create temp file first NSDataWritingWithoutOverwriting - prevent overwriting an existing file

Reading NSData [NSData alloc] initwithcontentsoffile: path options:nsdatareadingmappedifsafe error:&error]; NSDataReadingMappedIfSafe - file should be mapped into virtual memory, if possible and safe NSDataReadingUncached - file should not be stored in the file-system caches NSDataReadingMappedAlways - map the file, if possible.

Writing NSString BOOL success = [mystring writetofile:path atomically:yes encoding:nsutf8stringencoding error:&error]; NSUTF8StringEncoding - 8-bit representation of Unicode characters NSASCIIStringEncoding - Strict 7-bit ASCII encoding within 8-bit chars.

Reading NSString [NSData alloc] initwithcontentsoffile:path encoding:nsutf8stringencoding error:&error];

Writing/Reading NSString and NSData DEMO

NSFileManager NSFileManager *filemanager = [NSFileManager defaultmanager]; Providing a convenient way to: create read move copy delete files and directories.

NSFileManager NSFileManager *filemanager = [NSFileManager defaultmanager]; NSString *documentspath = [NSSearchPathForDirectoriesInDomains(NSDocumentDir ectory, NSUserDomainMask, YES) firstobject]; NSString *filepath = [documentspath stringbyappendingpathcomponent:@"file.txt"]; BOOL fileexists = [filemanager fileexistsatpath:filepath];

NSFileManager - list of files NSFileManager *filemanager = [NSFileManager defaultmanager]; NSArray *urls = [filemanager URLsForDirectory:NSDocumentDirectory indomains:nsuserdomainmask]; NSArray *files = [filemanager contentsofdirectoryaturl: [urls firstobject] includingpropertiesforkeys:nil options:nsdirectoryenumerationskipshiddenfiles error:&error];

NSFileManager - list of files [filemanager contentsofdirectoryaturl:[urls firstobject] includingpropertiesforkeys:nil options:nsfilebusy error:&error]; NSFileAppendOnly - The key in a file attribute dictionary whose value indicates whether the file is read-only. NSFileBusy - The key in a file attribute dictionary whose value indicates whether the file is busy. NSFileCreationDate - The key in a file attribute dictionary whose value indicates the file's creation date NSFileType - The key in a file attribute dictionary whose value indicates the file's type. NSDirectoryEnumerationSkipsHiddenFiles - Do not enumerate hidden files....

NSFileManager - list of files NSPredicate *predicate = [NSPredicate predicatewithformat:@"pathextension == 'png'"]; for (NSURL *fileurl in [contents filteredarrayusingpredicate:predicate]) { // Enumerate each.png file in directory }

NSFileManager - create/delete directory NSFileManager *filemanager = [NSFileManager defaultmanager]; NSString *documentspath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstobject]; NSString *imagespath = [documentspath stringbyappendingpathcomponent:@"images"]; if (![filemanager fileexistsatpath:imagespath]) { [filemanager createdirectoryatpath:imagespath withintermediatedirectories:no attributes:nil error:nil]; } BOOL deletesucess = [filemanager removeitematpath:imagespath error:&error];

NSFileManager - copy/move directory BOOL success = [filemanager moveitematpath:source topath:destination error:&error]; BOOL success = [filemanager copyitematurl:source tourl:destination error:&error];

NSFileManager DEMO

Property List

Property List XML Property List Standard Property List Editable by hand Device Independent Binary Property List Fast loading ASCII Legacy Property List Read only

Property List - supported types Abstract type XML element Cocoa class Core Foundation type array <array> NSArray CFArray dictionary <dict> NSDictionary CFDictionary string <string> NSString CFString data <data> NSData CFData date <date> NSDate CFDate number - integer <integer> NSNumber (intvalue) CFNumber number - floating point <real> NSNumber (floatvalue) CFNumber Boolean <true/> or <false/> NSNumber (boolvalue == YES or boolvalue == NO) CGBoolean

Property List - reading [NSPropertyListSerialization propertylistwithdata:data options:nspropertylistimmutable format:&format error:&error]; NSPropertyListImmutable - Specifies that the property list should be immutable. NSPropertyListMutableContainers - Causes the returned property list to have mutable containers but immutable leaves. NSPropertyListMutableContainersAndLeaves - Causes the returned property list to have mutable containers and leaves.

Property List - reading [NSPropertyListSerialization propertylistwithdata:data options:nspropertylistimmutable format:&format error:&error]; NSPropertyListOpenStepFormat - Specifies the ASCII property list format inherited from the OpenStep APIs. NSPropertyListXMLFormat_v1_0 - Specifies the XML property list format. NSPropertyListBinaryFormat_v1_0 - Specifies the binary property list format.

Property List - writing [NSPropertyListSerialization datawithpropertylist:plist format:nspropertylistxmlformat_v1_0 options:0 error:&error]; Property list must have one object as the root object. The option parameter is currently unused. Unsupported types will fail with an error.

Property List DEMO

JSON JSON stands for JavaScript Object Notation. It is a human readable format used to transmit data. JSON is formatted in attribute-value pairs. It is an alternative to XML for sending data across the network.

JSON - types Primitive JavaScript Types: String, Boolean, Number, Null Arrays are indicated by brackets - [] Objects are indicated by braces - {} Objects are collection of name-value pairs. Use commas to add additional fields.

JSON - NSJSONSerialization Convert JSON to foundation objects or can convert foundation to JSON The top level object is an NSArray or an NSDictionary All objects are insentence of NSString, NSNumber, NSArray, NSDictionary or NSNull All dictionary keys are NSString

JSON - Decoding +JSONObjectWithData:options:error: +JSONObjectWithStream:options:error:

JSON - Encoding +datawithjsonobject:options:error +writejsonobject:tostream:options:error

JSON DEMO

Core Data Managed Object Context Presistent Store Managed Objects Modeling Objects Fetch Request