NSDictionary 中的 32 位无符号整数
我正在开发 LiveJournal.com 客户端,我有一个问题。请你解释一下这是什么意思吗?
标量 当安全性为 usemask 时相关。一个 32 位无符号整数,表示允许用户的哪些朋友组查看此帖子。打开位 0 以允许任何定义的好友读取它。否则,为每个应该允许读取它的朋友组打开位 1-30。位 31 被保留。
例如,如果我想查看 id=6 的组,我需要在 NSMutableDictionary 中添加什么?我不明白...
I am developing LiveJournal.com client and i have one question. Can u, please, explain what does it mean?
scalar Relevant when security is usemask. A 32-bit unsigned integer representing which of the user's groups of friends are allowed to view this post. Turn bit 0 on to allow any defined friend to read it. Otherwise, turn bit 1-30 on for every friend group that should be allowed to read it. Bit 31 is reserved.
What am i need to add in NSMutableDictionary if i want to see, for example, group with id=6? I don't understand...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
安全实现的工作原理是授权或禁止一组朋友阅读日记/文本。
假设最多有 30 个可能的组,因为 bit-0 是特定的,而 bit-31 是保留的。
安全性采用
unsigned int
编码,即32位,其中bit0到bit31具有特殊含义。1
,则允许任何朋友进行读取访问。0
,则表示检查接下来的 30 位(bit1 到 30),以查看组i
(来自位i
) 具有读取权限(位设置为1
)或没有读取权限(位设置为0
)。unsigned int
可以表示为十进制值 11(0...01011 或 8+3),
其中位 0、1 和 3 设置为 1,其他位设置为 1被设置为 0。
因此,要检查朋友是否可以访问日记,请获取日记访问位,例如
您看到第一位是 1,因此所有组(所有朋友)都可以授权。
如果访问的
第一位是0,那么您必须根据上面的访问检查组号。假设组号为 1,您对照上面的访问权限进行检查
,您会发现组 1 已获得授权。如果您希望
组 1 未获得授权。
对于第3组和第30组,也已授权访问:
(MSb.bit31设置为
1
,但其值是保留的,因此您不必打扰它的值)The security implementation works by authorizing or no a group of friends to read a journal/text.
This assume there is a maximum of 30 possible groups, as bit-0 is specific, and bit-31 is reserved.
The security is coded on an
unsigned int
, meaning 32 bits, of which bit0 to bit31 have a special meaning.1
allows any friend the read access.0
, it means that the next 30 bits, bit1 to 30, are checked to see if the groupi
(from biti
) has read access (bit set to1
) or no (bit set to0
).An
unsigned int
can be represented asfor instance the decimal value of 11 (0...01011, or 8+3) is represented as
where bit 0, 1 and 3 are set to 1, the others are set to 0.
So, to check if a friend has access to a journal, take the journal access bits, for instance
you see that the first bit is 1, so all groups (all friends) are authorized.
If the access would be
the first bit is 0, so you have to check the group number against the access above. Say the group number is 1, you check against the access above
and you see that the group 1 is authorized. If you would have
the group 1 is not authorized.
For groups 3 and 30, the access is also authorized:
(The MSb. bit31 is set to
1
, but its value is reserved, so you shouldn't bother its value)