A 32-bit unsigned integer in NSDictionary
I am developing LiveJournal.com client and 开发者_如何学JAVAi 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...
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.
- the LSb, bit0, if set to
1
allows any friend the read access. - if bit0 is
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 as
bit 31 bit 0
v v
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
for instance the decimal value of 11 (0...01011, or 8+3) is represented as
00000000000000000000000000001011
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
11000000000000000000000000001011
you see that the first bit is 1, so all groups (all friends) are authorized.
If the access would be
11000000000000000000000000001010
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
11000000000000000000000000001010
1
^
group one
and you see that the group 1 is authorized. If you would have
11000000000000000000000000001000
the group 1 is not authorized.
For groups 3 and 30, the access is also authorized:
11000000000000000000000000001000
* *
(The MSb. bit31 is set to 1
, but its value is reserved, so you shouldn't bother its value)
精彩评论