如何使用NSLineSeparatorCharacter和NSParagraphSeparatorCharacter? [英] How to use NSLineSeparatorCharacter and NSParagraphSeparatorCharacter?
问题描述
我想知道如何使用常量NSLineSeparatorCharacter
和NSParagraphSeparatorCharacter
作为函数的参数,而不是对\n
进行硬编码.
I wonder how I can use the constants NSLineSeparatorCharacter
and NSParagraphSeparatorCharacter
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];
...或...
Object* obj = [[Object alloc] initWithSeparator:NSParagraphSeparatorCharacter];
Apples 字符串编程指南/段落和但是,换行符没有帮助.
Apples String Programming Guide / Paragraphs and Line Breaks was not helpful, though.
推荐答案
正确的参数类型为unichar-无需进行任何转换?如果以后要创建NSString,则必须使用
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];
这篇关于如何使用NSLineSeparatorCharacter和NSParagraphSeparatorCharacter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!