IT English Collection(10) of Object encoding

1 前言

    今天我们来学习一篇关于对象编码的文章,具体内容如下。

2 详述

2.1 原文

    Object encoding converts an object’s class identity and state to a format that can be stored or transferred between processes. The class type and instance data are written to a byte stream that can persist after a program terminates. When the program is launched again, a newly allocated object can decode the storedrepresentation of itself and restore itself to its previous runtime state. Encoding usually occursin concert with archiving, which puts a graph of objects into a format (an archive) that can be written to the file system; unarchiving operates on an archive, asking each object in the stored graph to decode itself.


    Object encoding is also used in the OS Xdistributed objects API for transferring objects from one process to another. However, its most common use is for archiving, which like a property list, is amechanism for object persistence.

How to Encode and Decode Objects
    For your subclass to encode and decode its instances, it must conform to the NSCoding protocol and implement two methods: initWithCoder: and encodeWithCoder:. When a program unarchives or archives an object graph, these methods are invoked. In the encodeWithCoder: method, you encode the values of an object’s important instance variables; in the initWithCoder: method, you decode those values andreassign them to their instance variables. If an object receives an initWithCoder: message, none of its initializer methods are invoked.

    The sole argument of initWithCoder: and encodeWithCoder: is an NSCoder object whose purpose is to perform theactual decoding or encoding. Because NSCoder is an abstract class, the coder object is in mostcases an instance of one of the following concrete subclasses: NSKeyedArchiver, NSKeyedUnarchiver, NSArchiver, NSUnarchiver. The archiver classes declare methods for encoding an object’s instance variables; the unarchiver classes declare methods for decoding instance variables.

    The NSCoder methods work on objects, scalars, C arrays, structures, and strings, and on pointers to these types. Before you encode or decode an instance variable of your own class, be sure to first invoke the superclass implementation of initWithCoder: or encodeWithCoder:. When you decode objects from the byte stream, be sure to retain or copy them when you assign them to their instance variables.

Keyed Versus Sequential Archiving
    Two of the concrete NSCoder subclasses are different from each other in a fundamental way. The “keyed” archiver class (NSKeyedArchiver and NSKeyedUnarchiver) associate an encoded value with a string key and use that same key when decoding that value; thus instance variables can be encoded and decoded in any sequence. With the other type of coder (NSArchiver and NSUnarchiver) you encode instance variables in a certain sequence, and you must decode them in the same sequence. The sequential coders should be used only withlegacy code; new subclasses should use keyed archive coders.

2.2 生词

representation[,reprɪzen'teɪʃ(ə)n] n. 代表;表现;

in concert with相呼应;与合作;和一致

distributed[dɪ'strɪbjʊtɪd]  adj. 分布式的,分散式的

mechanism['mek(ə)nɪz(ə)m]  n. 机制;原理

conform[kən'fɔːm] vi. 符合;遵照

reassign[riːə'saɪn] vt. 再分配;再指定

sole[səʊl]  n. 基础;  adj. 唯一的;单独的;仅有的

actual['æktʃʊəl; -tjʊəl] adj. 真实的,实际的;

in most cases 大部分情况下;

concrete['kɒŋkriːt] adj. 具体的;有形的

scalars['skeɪlə] n. [数] 标量;[数] 数量

Versus['vɜːsəs] prep. 对;与...相对;对抗

Sequential[sɪ'kwenʃ(ə)l] adj. 连续的;相继的;

fundamental[fʌndə'ment(ə)l]  adj. 基本的,根本的

legacy['legəsɪ]  n. 遗赠,遗产

3 结语

    以上是所有内容,希望对大家有所帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Word frequency list of American English(美国英语词频列表)是一个将常用英语单词按照使用频率进行排序的列表。这个列表通常是通过收集和分析大量的书籍、文章、报纸、网站和其他文本资料得出的。 这个词频列表对于学习英语、赋予单词重要性以及构建自然语言处理系统都非常有用。它可以帮助学习者了解和记忆最常用的英语单词,并通过重复的使用来提高英语的流利程度。对于写作和口语表达而言,词频列表可以指导人们使用最流行和自然的语言表达。 词频列表还可以在自然语言处理任务中起到重要的作用。在机器翻译、语音识别、信息检索等任务中,词频是构建模型和算法的基础。通过了解哪些词汇最常见,我们可以更好地理解和处理英文输入,并增强自然语言处理系统的准确性和效率。 在构建这个词频列表时,研究人员通常会先选择一个大型的文本语料库,然后利用计算机程序对其中的单词进行统计和排序。这个过程包括去除标点符号、特殊字符并将单词转换为小写形式,以便于准确统计每个单词的出现次数。最终,研究人员将计算结果按照频率从高到低排列,形成词频列表。 值得注意的是,这个词频列表是动态的,随着语言的演变和时代的变迁,单词的使用频率也会发生变化。因此,研究人员会不断更新和修订这个列表,以保证其实用性和准确性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值