开发者

How to use NSLineSeparatorCharacter and NSParagraphSeparatorCharacter?

开发者 https://www.devze.com 2023-01-19 07:34 出处:网络
I wonder how I can use the constants NSLineSeparatorCharacter and NSParagraphSeparatorChar开发者_如何学Cacter as a parameter to a function instead of hard coding \\n.

I wonder how I can use the constants NSLineSeparatorCharacter and NSParagraphSeparatorChar开发者_如何学Cacter as a parameter to a function instead of hard coding \n.

- (id)initWithSeparator:(id)separator {
 m_separator = separator;
}

What would be the correct parameter type and what conversion needs to be done?

Depending on the file contents I wish to call the function like ...

Object* obj = [[Object alloc] initWithSeparator:NSLineSeparatorCharacter];

... or ...

Object* obj = [[Object alloc] initWithSeparator:NSParagraphSeparatorCharacter];

Apples String Programming Guide / Paragraphs and Line Breaks was not helpful, though.


The correct parameter type would be unichar - no need to convert anything? If you want to create an NSString later, you'll have to use something like

    unichar myChar = NSParagraphSeparatorCharacter;
    NSString *myString = [NSString stringWithCharacters:&myChar length:1];
0

精彩评论

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