CN108664507A - User information treating method and apparatus - Google Patents
User information treating method and apparatus Download PDFInfo
- Publication number
- CN108664507A CN108664507A CN201710205216.5A CN201710205216A CN108664507A CN 108664507 A CN108664507 A CN 108664507A CN 201710205216 A CN201710205216 A CN 201710205216A CN 108664507 A CN108664507 A CN 108664507A
- Authority
- CN
- China
- Prior art keywords
- user information
- key
- data storage
- user
- storage object
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention provides a kind of user information treating method and apparatus, wherein this method includes:Create QTUserInfo classes;Calling+(AccountManager*) sharedManager function creation user informations handle singleton component;Singleton component call writeUserInfoToDefault function pair user informations are handled by user information to be stored.The user information treating method and apparatus provided through the embodiment of the present invention, can be managed collectively user information.
Description
Technical field
The present invention relates to technical field of data processing, in particular to a kind of user information treating method and apparatus.
Background technology
Currently, as apple terminal (iphone, ipad) is used by more and more users, apple terminal passes through default
IOS systems application software that user information and user are downloaded, multi-medium data store, with for users to use.
In the related technology, IOS systems can be determined first in file system and be used after receiving user information input by user
Then the memory space of family information stores user information into determining memory space, and establish the index text of user information
Part.
In realizing process of the present invention, inventor has found that at least there are the following problems in the prior art:
Inventor has found that IOS systems are more at random to the storage of user information in the related technology under study for action.
Invention content
In view of this, the embodiment of the present invention is designed to provide a kind of user information treating method and apparatus, with to
Family information is managed collectively.
In a first aspect, an embodiment of the present invention provides a kind of user information processing methods, including:
QTUserInfo classes are created, the QTUserInfo classes include:WriteUserInfoToDefault functions,
LoadUserInfoFromDefault functions and clearDefault functions;The writeUserInfoToDefault functions
For being stored to user information;The loadUserInfoFromDefault functions are used to carry out the user information
It reads;The clearDefault functions are for being purged the user information;
Calling+(AccountManager*) sharedManager function creation user informations handle singleton component;
It is handled described in writeUserInfoToDefault function pairs described in singleton component call by the user information
User information is stored.
With reference to first aspect, an embodiment of the present invention provides the first possible embodiments of first aspect, wherein:Institute
It states and user's letter described in writeUserInfoToDefault function pairs described in singleton component call is handled by the user information
Breath is stored, including:
User information is obtained, the user information includes:User information title and specific object value;
WriteUserInfoToDefault function creations described in singleton component call are handled by the user information
First data storage object of NSUserDefaults types;
By first data storage object using the user information title and the specific object value as with
The key and value of family information key-value pair generate the user information key-value pair of the user information;
It is stored the key as the index information of the user information into disk, and stores described value in disk.
With reference to first aspect, an embodiment of the present invention provides second of possible embodiments of first aspect, wherein:Institute
It states through first data storage object using the user information title and the specific object value as user information
The key and value of key-value pair generate the user information key-value pair of the user information, including:
Assignment is carried out to the user information title, obtains the mark of the user information title;
By first data storage object using the mark of the user information and the specific object value as
The key and value of user information key-value pair generate the user information key-value pair of the user information.
With reference to first aspect, an embodiment of the present invention provides the third possible embodiments of first aspect, wherein:Institute
The method of stating further includes:
User information read requests are obtained, the user information read requests carry user's user information to be read
The mark of user information title;
LoadUserInfoFromDefault function creations described in singleton component call are handled by the user information
Second data storage object of NSUserDefaults types;
The corresponding user information key of mark of the user information title is inquired by second data storage object
Value pair, and user's user information to be read is obtained from the user information key-value pair;
The user information inquired is returned into the user.
With reference to first aspect, an embodiment of the present invention provides the 4th kind of possible embodiments of first aspect, wherein:Institute
The method of stating further includes:
Create clearDefault functions;
First data storage object and described second are obtained by preset standardUserDefaults functions
Data storage object;
Pass through the first data storage object described in the clearDefault function pairs and second data storage object
It is purged operation;
It calls at the first data storage object and second data storage object described in preset setObject function pairs
The user information key-value pair managed is purged operation.
Second aspect, the embodiment of the present invention also provide a kind of user information processing unit, including:
Class creation module, for creating QTUserInfo classes, the QTUserInfo classes include:
WriteUserInfoToDefault functions, loadUserInfoFromDefault functions and clearDefault functions;It is described
WriteUserInfoToDefault functions are for storing user information;The loadUserInfoFromDefault
Function is for being read out the user information;The clearDefault functions are used to carry out the user information clear
It removes;
Singleton component creation module, for calling+(AccountManager*) sharedManager function creation users
Information processing singleton component;
Subscriber information storing module, for being handled described in singleton component call by the user information
User information is stored described in writeUserInfoToDefault function pairs.
In conjunction with second aspect, an embodiment of the present invention provides the first possible embodiments of second aspect, wherein:Institute
Subscriber information storing module is stated, including:
User information acquiring unit, for obtaining user information, the user information includes:User information title and specific
Attribute value;
Data storage object creating unit, for being handled described in singleton component call by the user information
First data storage object of writeUserInfoToDefault function creation NSUserDefaults types;
Key-value pair generation unit, for by first data storage object by the user information title and the tool
Body attribute value generates the user information key-value pair of the user information respectively as the key and value of user information key-value pair;
Storage unit, for being stored the key as the index information of the user information into disk, and in disk
Middle storage described value.
In conjunction with second aspect, an embodiment of the present invention provides second of possible embodiments of second aspect, wherein:Institute
Key-value pair generation unit is stated, including:
Assignment subelement obtains the mark of the user information title for carrying out assignment to the user information title;
Key-value pair generates subelement, for by first data storage object by the mark of the user information and institute
Key and value of the specific object value respectively as user information key-value pair are stated, the user information key-value pair of the user information is generated.
In conjunction with second aspect, an embodiment of the present invention provides the third possible embodiments of second aspect, wherein:Institute
Stating device further includes:
Read requests acquisition module, for obtaining user information read requests, the user information read requests carry
The mark of the user information title of user's user information to be read;
Data storage object creation module, for being handled described in singleton component call by the user information
Second data storage object of loadUserInfoFromDefault function creation NSUserDefaults types;
Enquiry module, the mark for inquiring the user information title by second data storage object correspond to
User information key-value pair, and user's user information to be read is obtained from the user information key-value pair;
Information return module, for the user information inquired to be returned to the user.
In conjunction with second aspect, an embodiment of the present invention provides the 4th kind of possible embodiments of second aspect, wherein:Institute
Stating device further includes:
Creation module, for creating clearDefault functions;
Read module, for obtaining the first data storage pair by preset standardUserDefaults functions
As with second data storage object;
First removes module, for passing through the first data storage object described in the clearDefault function pairs and described
Second data storage object is purged operation;
Second removes module, for calling the first data storage object described in preset setObject function pairs and described
The processed user information key-value pair of second data storage object is purged operation.
User information treating method and apparatus provided in an embodiment of the present invention handles singleton component by creating user information
Above-mentioned user information is stored, compared with IOS systems in the related technology are more at random to the storage of user information, Ke Yitong
It crosses the user information processing singleton component created user information is uniformly processed, has the advantages that storage is efficient and convenient.
To enable the above objects, features and advantages of the present invention to be clearer and more comprehensible, preferred embodiment cited below particularly, and coordinate
Appended attached drawing, is described in detail below.
Description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below will be to needed in the embodiment attached
Figure is briefly described, it should be understood that the following drawings illustrates only certain embodiments of the present invention, therefore is not construed as pair
The restriction of range for those of ordinary skill in the art without creative efforts, can also be according to this
A little attached drawings obtain other relevant attached drawings.
Fig. 1 shows the structure diagram that can be applied to the terminal of the apple in the embodiment of the present invention;
Fig. 2 shows a kind of flow charts for user information processing method that the embodiment of the present invention 1 is provided;
Fig. 3 is shown in the user information processing method that the embodiment of the present invention 1 is provided, and reads the specific side of user information
The flow chart of method;
Fig. 4 shows a kind of structural schematic diagram for user information processing unit that the embodiment of the present invention 2 is provided.
Icon:100- apple terminals;102- memories;104- storage controls;106- processors;108- Peripheral Interfaces;
110- radio-frequency modules;112- audio-frequency modules;114- Touch Screens;116- communication buses/signal wire;400- class creation modules;
402- singleton component creation modules;404- subscriber information storing modules.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
Middle attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is only
It is a part of the embodiment of the present invention, instead of all the embodiments.The present invention being usually described and illustrated herein in the accompanying drawings is real
Applying the component of example can be arranged and designed with a variety of different configurations.Therefore, below to provide in the accompanying drawings the present invention
The detailed description of embodiment is not intended to limit the range of claimed invention, but is merely representative of the selected reality of the present invention
Apply example.Based on the embodiment of the present invention, the institute that those skilled in the art are obtained without making creative work
There is other embodiment, shall fall within the protection scope of the present invention.
Fig. 1 shows a kind of structure diagram for the apple terminal that can be applied in the embodiment of the present invention.As shown in Figure 1, apple
Fruit terminal 100 includes memory 102, storage control 104, one or more (one is only shown in figure) processors 106, peripheral hardware
Interface 108, radio-frequency module 110, audio-frequency module 112, Touch Screen 114 etc..These components by one or more communication bus/
Signal wire 116 mutually communicates.
Memory 102 can be used for storing software program and module, such as the user information processing side in the embodiment of the present invention
Method and the corresponding program instruction/module of device, processor 106 by operation be stored in software program in memory 102 and
Module, to perform various functions application and data processing, such as user information processing method provided in an embodiment of the present invention.
Memory 102 may include high speed random access memory, may also include nonvolatile memory, such as one or more magnetic
Property storage device, flash memory or other non-volatile solid state memories.Processor 106 and other possible components are to storage
The access of device 102 can carry out under the control of storage control 104.
Peripheral Interface 108 couples various input/output devices to processor 106 and memory 102.In some implementations
In example, Peripheral Interface 108, processor 106 and storage control 104 can be realized in one single chip.In some other reality
In example, they can be realized by independent chip respectively.
Radio-frequency module 110 is used to receive and transmit electromagnetic wave, realizes the mutual conversion of electromagnetic wave and electric signal, thus with
Communication network or other equipment are communicated.
Audio-frequency module 112 provides a user audio interface, may include that one or more microphones, one or more raises
Sound device and voicefrequency circuit.
Touch Screen 114 provides an output and input interface simultaneously between apple terminal 100 and user.Specifically,
Touch Screen 114 shows video output to user, the content of these videos output may include word, figure, video and its arbitrary
Combination.
It is appreciated that structure shown in FIG. 1 is only to illustrate, apple terminal 100 may also include it is more than shown in Fig. 1 or
Less component, or with the configuration different from shown in Fig. 1.Each component shown in Fig. 1 may be used hardware, software or its
Combination is realized.
Currently, IOS systems after receiving user information input by user, can first determine user information in file system
Memory space, then user information is stored in determining memory space, and establish the index file of user information.Invention
People has found that IOS systems are more at random to the storage of user information in the related technology under study for action.It is provided by the present application based on this
A kind of user information treating method and apparatus.
It should be noted that in the description of the present invention, term "center", "upper", "lower", "left", "right", "vertical",
The orientation or positional relationship of the instructions such as "horizontal", "inner", "outside" be based on the orientation or positional relationship shown in the drawings, merely to
Convenient for the description present invention and simplify description, do not indicate or imply the indicated device or element must have a particular orientation,
With specific azimuth configuration and operation, therefore it is not considered as limiting the invention.In addition, term " first ", " second ",
" third " is used for description purposes only, and is not understood to indicate or imply relative importance.
In addition, in the description of the present invention unless specifically defined or limited otherwise, term " installation ", " connects " connected "
Connect " it shall be understood in a broad sense, for example, it may be being fixedly connected, it may be a detachable connection, or be integrally connected;It can be machine
Tool connects, and can also be electrical connection;It can be directly connected, can also can be indirectly connected through an intermediary two members
Connection inside part.For the ordinary skill in the art, it can understand above-mentioned term in the present invention with concrete condition
Concrete meaning.
Embodiment 1
The present embodiment provides a kind of user information processing method, the executive agent of this method is above-mentioned apple shown in FIG. 1
Any application program for needing to handle user information in terminal, the application program handle singleton by creating user information
Component stores user information.
Flow chart shown in Figure 2, user information processing method, including:
Step 200 creates QTUserInfo classes.
Specifically, above-mentioned QTUserInfo classes include:WriteUserInfoToDefault functions,
LoadUserInfoFromDefault functions and clearDefault functions.
Above-mentioned writeUserInfoToDefault functions are for storing user information;It is above-mentioned
LoadUserInfoFromDefault functions are for being read out above-mentioned user information;Above-mentioned clearDefault functions are used
It is purged in above-mentioned user information.
Above-mentioned QTUserInfo classes include:QTUserInfo.h and QTUserInfo.m files, Ke Yi
User information defined in QTUserInfo.h files.The method for defining user information is the side using attribute defined in apple language
Method.Above-mentioned user information, including but not limited to:Cell-phone number, user's pet name and the user's gender of user.
Step 202, calling+(AccountManager*) sharedManager function creation user informations handle singleton group
Part.
Above-mentioned user information handles singleton component, can be apple terminal IOS systems in any apply starting every time
When using singleton design pattern, by function+(AccountManager*) sharedManager create to user information into
The singleton component that row is uniformly processed.
Above-mentioned singleton component, is exactly an object, this object is the Life Cycle for being present in any application in IOS systems
It phase, can only be by creating its application call, which cannot repeat to create, excessive interior of consumption that will not be additional
It deposits.When the establishment its application is stopped by user, which can also terminate therewith.
Above-mentioned user information handles singleton component, has used the design pattern of singleton, and singleton design pattern has been used use
In the information management of family, the characteristic of singleton is:An object is only created, this object cannot repeat to create, additional will not disappear
Consume excessive memory;User information is all stored in the user information processing singleton component of establishment.
The most prominent advantage of user information processing singleton component is that the access site of user information is unique, is greatly facilitated
User information synchronizes, and the user information in IOS systems under any program is updated, and is all easy to read at other interfaces
Last updated data.
Step 204 stores above-mentioned user information by above-mentioned user information processing singleton component.
Specifically, above-mentioned steps 202 include the following steps (1) to (3):
(1) user information is obtained, above-mentioned user information includes:User information title and specific object value;
(2) the above-mentioned writeUserInfoToDefault function creations of singleton component call are handled by above-mentioned user information
First data storage object of NSUserDefaults types;
(3) by above-mentioned first data storage object using above-mentioned user information title and above-mentioned specific object value as
The key and value of user information key-value pair generate the user information key-value pair of above-mentioned user information;
(4) it using above-mentioned key as the storage of the index information of above-mentioned user information in disk, and stores in disk above-mentioned
Value.
In above-mentioned steps (1), when user information is:When user mobile phone number 1324567890, user information title is exactly:
User mobile phone number;Correspondingly, specific object value is exactly 1324567890.
The user information is the attribute information of application program required user in the process of implementation, no longer superfluous here
It states.
In above-mentioned steps (2), a user is write in the QTUserInfo.h files in QTUserInfo classes and stores letter
The statement of the method for breath:(such as-(void) writeUserInfoToDefault);One is write in QTUserInfo.m files
The realization of the method for user storage information:(function of such as-(void) writeUserInfoToDefault is realized).It needs each time
When executing storage operation to user information, it is only necessary to which user information is handled in singleton component call QTUserInfo classes
The method of user storage information can realize the store function of user information.
Above-mentioned first data storage object is a data management system, which opened using apple
Send out the included function acquisition of language.
In one embodiment, above-mentioned first data storage object is the included data management system of OC language apples.
Above-mentioned steps (3) specifically include following steps (31) to step (32):
(31) assignment is carried out to above-mentioned user information title, obtains the mark of above-mentioned user information title;
(32) mark of above-mentioned user information and above-mentioned specific object value are distinguished by above-mentioned first data storage object
As the key and value of user information key-value pair, the user information key-value pair of above-mentioned user information is generated.
In above-mentioned steps (31), obtain the mark of above-mentioned user information title process may be used it is existing any
The process identified to user information, no longer repeats one by one here.
In above-mentioned steps (32), [def setObject in apple language are used:(NSString*)obj forKey:
(NSString*) key] function command stores the user information key-value pair of generation.What obj was stored in above-mentioned function is object
(can be arbitrary user information), the key values in above-mentioned function statement are corresponding unique key assignments, can repeatedly call [def
setObject:(NSString*)obj forKey:(NSString*) key] method, change obj and key values store different
User information.
In above-mentioned steps (4), the function synchronize carried using apple development language is by the user information of generation
Key-value pair synchronizes in storage to disk, and the process of storage is similar to dictionary assignment, and which is not described herein again.
Above-mentioned NSUserDefaults refers to application program sandbox.In IOS systems, stored using NSUserDefaults
Mode is the most suitable storage mode used for user information.
Can be seen that by the description of above step (1) to step (4) will be given birth to using NSUserDefaults storage modes
At the data of user information key-value pair stored, can kill in application or when restarting, can still access
User information when using kill or restarting, improves the access efficiency of user information.
In conclusion user information processing method provided in this embodiment, singleton component is handled by creating user information
Above-mentioned user information is stored, compared with IOS systems in the related technology are more at random to the storage of user information, Ke Yitong
It crosses the user information processing singleton component created and unified storage is carried out to user information, have the advantages that storage is efficient and convenient.
By flow and step above to handling the mistake that singleton component stores user information by user information
Journey is described, and the process that user information is read out is described to handling singleton component by user information below.
Flow chart shown in Figure 3, above-mentioned user information processing method are further comprising the steps of:
Step 300 obtains user information read requests, and above-mentioned user information read requests carry user's use to be read
The mark of the user information title of family information.
The mark of user information title is that application program is stored in user information by above-mentioned user information processing singleton component
Self-defined afterwards and to the user information title distribution and relevant character string of user information.After being assigned, application program
The user information title of distribution and corresponding mark can be cached.
When application program determines that user wants using some user information, application program can in advance be divided according to mark
The result matched and user trigger the user information title used, determine that user thinks the mark of user information title to be used.
Step 302 handles the above-mentioned loadUserInfoFromDefault letters of singleton component call by above-mentioned user information
Number creates the second data storage object of NSUserDefaults types.
In above-mentioned steps 302, a user is write in the QTUserInfo.h files in QTUserInfo classes and reads letter
The statement of the method for breath:(such as-(void) loadUserInfoFromDefault);One is write in QTUserInfo.m files
The realization of the method for a user storage information:(function of such as-(void) loadUserInfoFromDefault is realized).It is each
It is secondary need to user information execute read operation when, it is only necessary to user information handle singleton component call QTUserInfo classes
In user's method for reading information can realize the read functions of user information.
Above-mentioned second data storage object, an and data management system similar with above-mentioned first data storage object should
Second data storage object is obtained using the included function of apple development language.
In one embodiment, above-mentioned second data storage object is the included data management system of OC language apples.
Step 304, the corresponding use of mark that above-mentioned user information title is inquired by above-mentioned second data storage object
Family information key-value pair, and user's user information to be read is obtained from above-mentioned user information key-value pair.
Wherein, above-mentioned user information key-value pair includes:Key that the mark of above-mentioned user information title generates and above-mentioned specific
The value of attribute value generation.
Specifically, above-mentioned steps 304 include step (1) in detail below to step (3):
(1) key for the user information key-value pair being generated in advance is obtained by above-mentioned second data storage object;
(2) determine from the user information key-value pair got to have by above-mentioned second data storage object with it is above-mentioned
The user information key-value pair of the identical key of mark of user information title;
(3) determine that the value in the corresponding above-mentioned user information key-value pair of the key is above-mentioned user above-mentioned user letter to be read
Breath.
In above-mentioned steps (2), [def objectForKey are used in apple language:(NSString*) key] function
It orders to obtain the value for the user information key-value pair being stored in disk.Key is the corresponding unique key assignments of storage object value, this step
It suddenly can be by repeatedly calling [def objectForKey:(NSString*) key] function reads multiple user informations.
The above-mentioned user information inquired is returned to above-mentioned user by step 306.
Specifically, it in above-mentioned steps 306, needs to first pass through user information processing singleton component and gets user information,
Then above-mentioned user information could be returned to above-mentioned user.
In conclusion user information read method provided in this embodiment, can be handled single by the user information of establishment
Example component carries out unified reading to user information, has the advantages that efficient and convenient.
Further, in order to which when application program is hung up or do not rerun, the user for dischargeing application program establishment believes
Breath processing singleton component, the present embodiment also propose a kind of flow of the removing of user information, user information provided in this embodiment
Processing method, further comprising the steps of (1) to step (4):
(1) clearDefault functions are created;
(2) above-mentioned first data storage object and above-mentioned the are obtained by preset standardUserDefaults functions
Two data storage objects;
(3) pass through above-mentioned first data storage object of above-mentioned clearDefault function pairs and the storage pair of above-mentioned second data
As being purged operation;
(4) preset above-mentioned first data storage object of setObject function pairs and the storage pair of above-mentioned second data are called
As processed above-mentioned user information key-value pair is purged operation.
In above-mentioned steps (2), in IOS systems, the first data storage object of NSUserDefaults generations is used
With above-mentioned second data storage object, can directly be obtained by standardUserDefaults functions.
In above-mentioned steps (3), by above-mentioned first data storage object of above-mentioned clearDefault function pairs and above-mentioned
The process that second data storage object is purged operation specifically includes:Call function self.phoneNum=nil;By first
The attribute of data storage object and above-mentioned second data storage object is set as empty, that is, removes the first data storage object and upper
State the second data storage object.
In above-mentioned steps (4), using setObject functions by some key and correspondence in user information key-value pair
Value be set as empty, to be purged operation to user information key-value pair.Being set as the functional based method of sky is:[def
setObject:nil forKey:@"phoneNum"]。
Can be seen that by the description of above step (1) to step (4) can be completed using above-mentioned clearDefault
Data empty.The data being not only blanked in the first data storage object and above-mentioned second data storage object, while to list
The user information key-value pair that example generates has carried out null clear operation, and no data remains at the end of application program, it is easy to realize clear
Empty data.
Embodiment 2
Structural schematic diagram shown in Figure 4, it is above-mentioned for executing the present embodiment provides a kind of user information processing unit
User information processing method, including:
Class creation module 400, for creating QTUserInfo classes, above-mentioned QTUserInfo classes include:
WriteUserInfoToDefault functions, loadUserInfoFromDefault functions and clearDefault functions;It is above-mentioned
WriteUserInfoToDefault functions are for storing user information;Above-mentioned loadUserInfoFromDefault
Function is for being read out above-mentioned user information;Above-mentioned clearDefault functions are used to carry out above-mentioned user information clear
It removes;
Singleton component creation module 402, for calling+(AccountManager*) sharedManager function creations use
Family information processing singleton component;
Subscriber information storing module 404, it is above-mentioned for handling singleton component call by above-mentioned user information
The above-mentioned user information of writeUserInfoToDefault function pairs is stored.
In conclusion user information processing unit provided in this embodiment, singleton component is handled by creating user information
Above-mentioned user information is stored, compared with IOS systems in the related technology are more at random to the storage of user information, Ke Yitong
It crosses the user information processing singleton component created and unified storage is carried out to user information, have the advantages that storage is efficient and convenient.
Specifically, above-mentioned subscriber information storing module, including:
User information acquiring unit, for obtaining user information, above-mentioned user information includes:User information title and specific
Attribute value;
Data storage object creating unit, it is above-mentioned for handling singleton component call by above-mentioned user information
First data storage object of writeUserInfoToDefault function creation NSUserDefaults types;
Key-value pair generation unit, for by above-mentioned first data storage object by above-mentioned user information title and above-mentioned tool
Body attribute value generates the user information key-value pair of above-mentioned user information respectively as the key and value of user information key-value pair;
Storage unit, for being stored above-mentioned key as the index information of above-mentioned user information into disk, and in disk
The middle above-mentioned value of storage.
In one embodiment, above-mentioned key-value pair generation unit, including:
Assignment subelement obtains the mark of above-mentioned user information title for carrying out assignment to above-mentioned user information title;
Key-value pair generates subelement, for by above-mentioned first data storage object by the mark of above-mentioned user information and
Key and value of the specific object value respectively as user information key-value pair are stated, the user information key-value pair of above-mentioned user information is generated.
By above description as can be seen that using NSUserDefaults storage modes by the user information key assignments of generation
To data store, can application kill either restart when still can access using kill or again
User information when startup improves the access efficiency of user information.
The process that user information is read out is described to handling singleton component by user information below.In order to right
User information is read out, and above-mentioned apparatus further includes:
Read requests acquisition module, for obtaining user information read requests, above-mentioned user information read requests carry
The mark of the user information title of user's user information to be read;
Data storage object creation module, it is above-mentioned for handling singleton component call by above-mentioned user information
Second data storage object of loadUserInfoFromDefault function creation NSUserDefaults types;
Enquiry module, the mark for inquiring above-mentioned user information title by above-mentioned second data storage object correspond to
User information key-value pair, and user's user information to be read is obtained from above-mentioned user information key-value pair;
Information return module, for the above-mentioned user information inquired to be returned to above-mentioned user.
In conclusion user information read method provided in this embodiment, can be handled single by the user information of establishment
Example component carries out unified reading to user information, has the advantages that efficient and convenient.
Further, in order to which when application program is hung up or do not rerun, the user for dischargeing application program establishment believes
Breath processing singleton component, the user information reading device that the present embodiment proposes further include:
Creation module, for creating clearDefault functions;
Read module, for obtaining above-mentioned first data storage pair by preset standardUserDefaults functions
As with above-mentioned second data storage object;
First removes module, for passing through above-mentioned first data storage object of above-mentioned clearDefault function pairs and above-mentioned
Second data storage object is purged operation;
Second removes module, for calling above-mentioned first data storage object of preset setObject function pairs and above-mentioned
The processed above-mentioned user information key-value pair of second data storage object is purged operation.
By above description as can be seen that emptying for data can be completed using above-mentioned clearDefault.It is not only clear
Data in empty first data storage object and above-mentioned second data storage object, while to user information key that singleton generates
Value is to having carried out null clear operation, and no data remains at the end of application program, it is easy to which realization empties data.
The computer program product for the carry out user information processing method that the embodiment of the present invention is provided, including store journey
The computer readable storage medium of sequence code, the instruction that above procedure code includes can be used for executing in previous methods embodiment
The method stated, specific implementation can be found in embodiment of the method, and details are not described herein.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed systems, devices and methods, it can be with
It realizes by another way.The apparatus embodiments described above are merely exemplary, for example, the division of the unit,
Only a kind of division of logic function, formula that in actual implementation, there may be another division manner, in another example, multiple units or component can
To combine or be desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or beg for
The mutual coupling, direct-coupling or communication connection of opinion can be by some communication interfaces, device or unit it is indirect
Coupling or communication connection can be electrical, machinery or other forms.
The unit illustrated as separating component may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, you can be located at a place, or may be distributed over multiple
In network element.Some or all of unit therein can be selected according to the actual needs to realize the mesh of this embodiment scheme
's.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it can also
It is that each unit physically exists alone, it can also be during two or more units be integrated in one unit.
It, can be with if the function is realized in the form of SFU software functional unit and when sold or used as an independent product
It is stored in a computer read/write memory medium.Based on this understanding, technical scheme of the present invention is substantially in other words
The part of the part that contributes to existing technology or the technical solution can be expressed in the form of software products, the meter
Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be
People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention.
And storage medium above-mentioned includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic disc or CD.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (10)
1. a kind of user information processing method, which is characterized in that including:
QTUserInfo classes are created, the QTUserInfo classes include:WriteUserInfoToDefault functions,
LoadUserInfoFromDefault functions and clearDefault functions;The writeUserInfoToDefault functions
For being stored to user information;The loadUserInfoFromDefault functions are used to carry out the user information
It reads;The clearDefault functions are for being purged the user information;
Calling+(AccountManager*) sharedManager function creation user informations handle singleton component;
User described in writeUserInfoToDefault function pairs described in singleton component call is handled by the user information
Information is stored.
2. according to the method described in claim 1, it is characterized in that, described handle singleton component call by the user information
User information is stored described in the writeUserInfoToDefault function pairs, including:
User information is obtained, the user information includes:User information title and specific object value;
WriteUserInfoToDefault function creations described in singleton component call are handled by the user information
First data storage object of NSUserDefaults types;
The user information title and the specific object value are believed as user by first data storage object
The key and value for ceasing key-value pair, generate the user information key-value pair of the user information;
It is stored the key as the index information of the user information into disk, and stores described value in disk.
3. according to the method described in claim 2, it is characterized in that, it is described by first data storage object by the use
Family name of the information and the specific object value generate the use of the user information respectively as the key and value of user information key-value pair
Family information key-value pair, including:
Assignment is carried out to the user information title, obtains the mark of the user information title;
By first data storage object using the mark of the user information and the specific object value as user
The key and value of information key-value pair generate the user information key-value pair of the user information.
4. according to the method described in claim 2, it is characterized in that, the method further includes:
User information read requests are obtained, the user information read requests carry the user of user's user information to be read
The mark of name of the information;
LoadUserInfoFromDefault function creations described in singleton component call are handled by the user information
Second data storage object of NSUserDefaults types;
The corresponding user information key-value pair of mark of the user information title is inquired by second data storage object,
And user's user information to be read is obtained from the user information key-value pair;
The user information inquired is returned into the user.
5. according to the method described in claim 4, it is characterized in that, the method further includes:
Create clearDefault functions;
First data storage object and second data are obtained by preset standardUserDefaults functions
Storage object;
It is carried out by the first data storage object described in the clearDefault function pairs and second data storage object
Clear operation;
Call the first data storage object and second data storage object described in preset setObject function pairs processed
The user information key-value pair be purged operation.
6. a kind of user information processing unit, which is characterized in that including:
Class creation module, for creating QTUserInfo classes, the QTUserInfo classes include:
WriteUserInfoToDefault functions, loadUserInfoFromDefault functions and clearDefault functions;It is described
WriteUserInfoToDefault functions are for storing user information;The loadUserInfoFromDefault
Function is for being read out the user information;The clearDefault functions are used to carry out the user information clear
It removes;
Singleton component creation module, for calling+(AccountManager*) sharedManager function creation user informations
Handle singleton component;
Subscriber information storing module, for being handled described in singleton component call by the user information
User information is stored described in writeUserInfoToDefault function pairs.
7. device according to claim 6, which is characterized in that the subscriber information storing module, including:
User information acquiring unit, for obtaining user information, the user information includes:User information title and specific object
Value;
Data storage object creating unit, for being handled described in singleton component call by the user information
First data storage object of writeUserInfoToDefault function creation NSUserDefaults types;
Key-value pair generation unit, for by first data storage object by the user information title and the specific category
Property value generates the user information key-value pair of the user information respectively as the key and value of user information key-value pair;
Storage unit for being stored the key as the index information of the user information into disk, and is deposited in disk
Store up described value.
8. device according to claim 7, which is characterized in that the key-value pair generation unit, including:
Assignment subelement obtains the mark of the user information title for carrying out assignment to the user information title;
Key-value pair generates subelement, for by first data storage object by the mark of the user information and the tool
Body attribute value generates the user information key-value pair of the user information respectively as the key and value of user information key-value pair.
9. device according to claim 7, which is characterized in that described device further includes:
Read requests acquisition module, for obtaining user information read requests, the user information read requests carry user
The mark of the user information title of user information to be read;
Data storage object creation module, for being handled described in singleton component call by the user information
Second data storage object of loadUserInfoFromDefault function creation NSUserDefaults types;
Enquiry module, the corresponding use of mark for inquiring the user information title by second data storage object
Family information key-value pair, and user's user information to be read is obtained from the user information key-value pair;
Information return module, for the user information inquired to be returned to the user.
10. device according to claim 9, which is characterized in that described device further includes:
Creation module, for creating clearDefault functions;
Read module, for by preset standardUserDefaults functions obtain first data storage object and
Second data storage object;
First removes module, for passing through the first data storage object and described second described in the clearDefault function pairs
Data storage object is purged operation;
Second removes module, for calling the first data storage object and described second described in preset setObject function pairs
The processed user information key-value pair of data storage object is purged operation.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710205216.5A CN108664507B (en) | 2017-03-31 | 2017-03-31 | User information processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710205216.5A CN108664507B (en) | 2017-03-31 | 2017-03-31 | User information processing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108664507A true CN108664507A (en) | 2018-10-16 |
CN108664507B CN108664507B (en) | 2022-03-22 |
Family
ID=63786701
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710205216.5A Active CN108664507B (en) | 2017-03-31 | 2017-03-31 | User information processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108664507B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102841780A (en) * | 2011-06-23 | 2012-12-26 | 阿里巴巴集团控股有限公司 | Method and equipment for creating and calling universal components |
US20130262400A1 (en) * | 2012-03-30 | 2013-10-03 | Huawei Technologies Co., Ltd. | Data index query method, apparatus and system |
CN103677843A (en) * | 2013-12-19 | 2014-03-26 | 深圳市迈桥科技有限公司 | Native capacity development method and device across mobile terminals |
CN105956006A (en) * | 2016-04-21 | 2016-09-21 | 贵州电网有限责任公司信息中心 | Structured query system for key value pair data storage |
CN106295360A (en) * | 2016-07-26 | 2017-01-04 | 深圳天珑无线科技有限公司 | The method and device of data storage |
US20170026356A1 (en) * | 2015-07-22 | 2017-01-26 | Here Global B.V. | Method and apparatus for generating an intelligent primary key facilitating faster object retrieval |
-
2017
- 2017-03-31 CN CN201710205216.5A patent/CN108664507B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102841780A (en) * | 2011-06-23 | 2012-12-26 | 阿里巴巴集团控股有限公司 | Method and equipment for creating and calling universal components |
US20130262400A1 (en) * | 2012-03-30 | 2013-10-03 | Huawei Technologies Co., Ltd. | Data index query method, apparatus and system |
CN103677843A (en) * | 2013-12-19 | 2014-03-26 | 深圳市迈桥科技有限公司 | Native capacity development method and device across mobile terminals |
US20170026356A1 (en) * | 2015-07-22 | 2017-01-26 | Here Global B.V. | Method and apparatus for generating an intelligent primary key facilitating faster object retrieval |
CN105956006A (en) * | 2016-04-21 | 2016-09-21 | 贵州电网有限责任公司信息中心 | Structured query system for key value pair data storage |
CN106295360A (en) * | 2016-07-26 | 2017-01-04 | 深圳天珑无线科技有限公司 | The method and device of data storage |
Non-Patent Citations (1)
Title |
---|
李亚格等: "基于iOS的移动办公系统设计与性能优化", 《计算机工程》 * |
Also Published As
Publication number | Publication date |
---|---|
CN108664507B (en) | 2022-03-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110399420B (en) | Export method, electronic equipment and medium of configurable Excel format | |
CN104199706B (en) | A kind of eMMC firmware upgrade method and its equipment | |
CN109446072A (en) | The generation method and device of test script | |
CN110351378A (en) | A kind of control method and system of internet of things equipment | |
CN110247811A (en) | A kind of alarm method and relevant apparatus of internet of things equipment | |
CN106126557A (en) | Page processing method and device | |
CN108279882B (en) | Framework generation method, device, equipment and computer readable medium | |
CN104601683A (en) | File download management method, mobile terminal and communication system | |
CN104469717A (en) | Short message sending method and device | |
CN108171189A (en) | A kind of method for video coding, video coding apparatus and electronic equipment | |
CN110427134A (en) | Data processing method, device, equipment and the readable storage medium storing program for executing of instant messaging | |
CN105630419B (en) | A kind of the subregion view sending method and management node of resource pool | |
CN105323309B (en) | A kind of method and device of bubble resource supplying | |
CN113407254B (en) | Form generation method and device, electronic equipment and storage medium | |
CN108874808A (en) | A kind of page elements interlock method, device and server | |
CN104317561A (en) | Method of interface operation | |
CN105550179A (en) | Webpage collection method and browser plug-in | |
CN116894413B (en) | Logic mapping method, device, equipment and storage medium based on hardware | |
CN108053034A (en) | Model parameter processing method, device, electronic equipment and storage medium | |
CN108038171A (en) | Method for writing data, device and data server | |
CN109521914A (en) | Restore the methods, devices and systems of data in file | |
CN104793837A (en) | Picture generation method and device | |
CN108664507A (en) | User information treating method and apparatus | |
CN110442059A (en) | Controlled device expanding method, device and control equipment | |
CN109325069A (en) | Method for processing business, device and the network equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20230714 Address after: Room 307, Building 3, No. 168, Luoyang Road, Minhang District, Shanghai, 201104 Patentee after: Shanghai Baoqi Information Technology Co.,Ltd. Address before: 430000 East Lake Development Zone, Wuhan City, Hubei Province, No. 1 Software Park East Road 4.1 Phase B1 Building 11 Building Patentee before: WUHAN DOUYU NETWORK TECHNOLOGY Co.,Ltd. |