开发者

What kind of data type is this?

开发者 https://www.devze.com 2022-12-28 16:48 出处:网络
In an class header I have seen something like this: enum { kAudioSessionProperty_Preferr开发者_开发知识库edHardwareSampleRate= \'hwsr\',// Float64

In an class header I have seen something like this:

enum {
    kAudioSessionProperty_Preferr开发者_开发知识库edHardwareSampleRate           = 'hwsr',   // Float64
    kAudioSessionProperty_PreferredHardwareIOBufferDuration     = 'iobd'   // Float32
};

Now I wonder what data type such an kAudioSessionProperty_PreferredHardwareSampleRate actually is?

I mean this looks like plain old C, but in Objective-C I would write @"hwsr" if I wanted to make it a string.

I want to pass such an "constant" or "enum thing" as argument to an method.


This converts to an UInt32 enum value using the ASCII value of each of the entries. This style have been around for a long time in Mac OS headers.

'hwsr' has the same value as if you had written 0x68777372, but is a lot more reader friendly. If you used the @"hwsr" style instead you would need more than 4 bytes to represent the same.

The advantage of using this style is that you are actually able to quickly identify the content of a raw data stream if you can see the ASCII values of it.

0

精彩评论

暂无评论...
验证码 换一张
取 消