Knowledge of the properties and methods of the archive class and the Solution archive class

Source: Internet
Author: User

The way to archive is to store data in ciphertext, or in binary storage. Archived properties and methods: Nskeyedarchiver foundation_export NSString * Const nsinvalidarchiveoperationexception; Foundation_export NSString * Const nsinvalidunarchiveoperationexception; The above two constants are used to handle exceptions, and one is used when archiving an archive. Sfoundation_export NSString * Const Nskeyedarchiverootobjectkey ns_available (10_9, 7_0);// The key word is whether the archive method of the class or the corresponding individual strength of the hair that is, are can use this keyword to act as the key word of the object.  Archivedrootdatawithobject:, Unarchiveobjectwithdata etc + (NSData *) Archiveddatawithrootobject: (ID) rootObject; Archive the object to data of type + (BOOL) Archiverootobject: (ID) rootobject tofile: (NSString *) path;//Rootobject object is written under path-developed paths-( Instancetype) Initforwritingwithmutabledata: (Nsmutabledata *) data; @property Nspropertylistformat OutputFormat; Nspropertylistformat This is an enumeration type typedef ns_enum (Nsuinteger, nspropertylistformat) {Nspropertylistopenstepformat =    kcfpropertylistopenstepformat,//plaintext Nspropertylistxmlformat_v1_0 = kcfpropertylistxmlformat_v1_0,//This is the format of XML NSPROPERTYLISTBINARYFORMAT_V1_0 = Kcfpropertylistbinaryformat_v1_0//This is a binary format};-(void) finishencoding;//complete encoding (archive) + (void) Setclassname: (NSString *) codedname Forclass: (Class) cls;-(void) Setclassname: (NSString *) Codedname Forclass: (Class) cls;//during the encoding process, the encoder first checks its own table of the encoder, If there are no mappings to the class that can be set accordingly. Set the class name of the archive + (NSString *) Classnameforclass: (Class) cls;-(NSString *) Classnameforclass: (Class) cls;//get the archived class name, Gets the mapping name in the class-(void) Encodeobject: (ID) objv forkey: (NSString *) key;-(void) Encodeconditionalobject: (ID) objv Forkey: ( NSString *) key;-(void) Encodebool: (BOOL) boolv forkey: (NSString *) key;-(void) Encodeint: (int) Intv Forkey: (NSString *)    Key Native int-(void) EncodeInt32: (int32_t) Intv forkey: (NSString *) key;-(void) EncodeInt64: (int64_t) Intv Forkey: ( NSString *) key;-(void) Encodefloat: (float) realv forkey: (NSString *) key;-(void) Encodedouble: (double) Realv Forkey: ( NSString *) key;-(void) Encodebytes: (const uint8_t *) BYTESP Length: (nsuinteger) lenv forkey: (NSString *) key;// Setting the corresponding value setting for the corresponding storage (archive) class, which is key, is usually set in the form of keywords and strings. In the Eg:person class: [Person enCodeobject:name forkey:@ "name"]; This means that the corresponding values are set]//the security Encoding (archive), encoding is a way to archive data, or encoding is a variety of ways, and archiving is a way of data storage. -(void) setrequiressecurecoding: (BOOL) b;//*** does not need to be archived to the archive by setting up a secure encoding (that is, the process is not a coherent process)//Security archive is just a way to ensure that all classes are safe to archive, When this method is yes, if a class does not have a secure archive, it will run out of exception. Note: The Getter method is nscoder in the parent class, and you can view it to learn more about the security encoding.    @interface Nskeyedarchiver:nscoder {@private void *_stream;    Nsuinteger _flags;    ID _delegate;    ID _containers;    ID _objects;    ID _objrefmap;    ID _replacementmap;    ID _classnamemap;    ID _conditionals;    ID _classes;    Nsuinteger _generickey;    void *_cache;    Nsuinteger _cachesize;    Nsuinteger _estimatedcount;    void *_reserved2;    ID _visited; void * __strong _reserved0;} Private Property Proxy method: @protocol nskeyedarchiverdelegate <NSObject> @optional//alternative-(ID) archiver: (Nskeyedarchiver *)    Archiver Willencodeobject: (ID) object; -(void) Archiver: (Nskeyedarchiver *) archiver Didencodeobject: (ID) object;//notification-(void) Archiver: (Nskeyedarchiver *) Archiver Willreplaceobject: (ID) Object WithobJect: (ID) newobject;-(void) Archiverwillfinish: (Nskeyedarchiver *) archiver;-(void) Archiverdidfinish: ( Nskeyedarchiver *) Archiver; Classification Method (object): @interface nsobject (nskeyedarchiverobjectsubstitution) @property (    ReadOnly) Class classforkeyedarchiver;-(ID) replacementobjectforkeyedarchiver: (Nskeyedarchiver *) archiver; + (Nsarray *) classfallbacksforkeyedarchiver; @end//encoding: Two methods of encoding @protocol nscoding (methods that must be implemented)-(void) Encodewithcoder: ( Nscoder *) acoder;//Encoding (Save)-(ID) Initwithcoder: (Nscoder *) Adecoder; Decode (GET) @end


The following are the properties and methods of the archive Nskeyedunarchiver

@interface Nskeyedunarchiver:nscoder {@private ID _delegate;    uint32_t _flags;    ID _objrefmap;    ID _replacementmap;    ID _nameclassmap;    ID _tmprefobjmap;    ID _refobjmap;    int32_t _generickey;    ID _data;    void *_offsetdata;    ID _containers;    ID _objects;    Const uint8_t *_bytes;    uint64_t _len;    ID _helper; void * __strong _reserved0;} Private properties, the basic and archived classes are the same. How to archive: + (ID) unarchiveobjectwithdata: (NSData *) data;+ (ID) unarchiveobjectwithfile: (NSString *) path;-(instancetype) Initforreadingwithdata: (NSData *) data;-(void) finishdecoding;+ (void) SetClass: (Class) CLS Forclassname: (NSString *) codedname;-(void) SetClass: (Class) CLS Forclassname: (NSString *) codedname;+ (Class) Classforclassname: (NSString *) codedname;-(Class) Classforclassname: (NSString *) codedname;-(BOOL) Containsvalueforkey: (NSString *) key;-(ID)     Decodeobjectforkey: (NSString *) key;-(BOOL) Decodeboolforkey: (NSString *) key;-(int) Decodeintforkey: (NSString *) key; May raise a range exception-(int32_T) Decodeint32forkey: (NSString *) key;-(int64_t) Decodeint64forkey: (NSString *) key;-(float) Decodefloatforkey: ( NSString *) key;-(double) Decodedoubleforkey: (NSString *) key;-(const uint8_t *) Decodebytesforkey: (NSString *) key Returnedlength: (Nsuinteger *) LENGTHP ns_returns_inner_pointer; -(void) setrequiressecurecoding: (BOOL) b ns_available (10_8, 6_0);//The method above is basically the same as the method in the archive class, but it is a reverse process. @protocol nskeyedunarchiverdelegate <NSObject> @optional//Error handling-(Class) Unarchiver: ( Nskeyedunarchiver *) Unarchiver cannotdecodeobjectofclassname: (NSString *) name originalclasses: (NSArray *) classNames  ; substitution-(ID) unarchiver: (Nskeyedunarchiver *) Unarchiver Diddecodeobject: (ID) ns_releases_argument object NS_   returns_retained; notification-(void) Unarchiver: (Nskeyedunarchiver *) Unarchiver Willreplaceobject: (ID) object withobject: (ID) NewObject;    Ded objects.-(void) Unarchiverwillfinish: (Nskeyedunarchiver *) unarchiver; Notifies the delegate that decoding are about to finish.-(void) uNarchiverdidfinish: (Nskeyedunarchiver *) unarchiver; Notifies the delegate that decoding have finished. @end system-Defined classification method: @interface NSObject ( nskeyedunarchiverobjectsubstitution) + (Class) classforkeyedunarchiver; @end


Summarize:

1. Archiving and archiving of data is the process of data storage and acquisition

2, archive and archive are inherited from the coding class Nscoder. Are the method class classes and methods that you need to use in the data archive stored procedure.




Knowledge of the properties and methods of the archive class and the Solution archive class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.