I am coming to Objective-C from C# without any intermediate knowledge of C. (Yes, yes, I will need to learn C at some point and I fully intend to.) In Apple’s Certificate, Key, and Trust Services Programming Guide, there is the following code:
static const UInt8 publicKeyIdentifier[] = "com.apple.sample.publickey\0";
static const UInt8 privateKeyIdentifier[] = "com.apple.sample.privatekey\0";
I have an NSString that I would like to use as an identifier here and for the life of me I can’t figure out how to get that into this data structure. Searching through Google has been fruitless also. I looked at the NSString Class Reference and looked at the UTF8String and getCharacters methods but I couldn’t get the product into the structure.
What’s the simple, easy trick I’m missing?
I think some people are missing the point here. Everyone has explained the two constant arrays that are being set up for the tags, but if you want to use an
NSString, you can simply add it to the attribute dictionary as-is. You don’t have to convert it to anything. For example:The rest of the example stays exactly the same. In this case, there is no need for the C string literals at all.