如何使用 NSLineSeparatorCharacter 和 NSParagraphSeparatorCharacter?
我想知道如何使用常量 NSLineSeparatorCharacter
和 NSParagraphSeparatorCharacter
作为函数的参数,而不是硬编码 \n
。
- (id)initWithSeparator:(id)separator {
m_separator = separator;
}
正确的参数类型是什么以及需要进行什么转换?
根据文件内容,我希望调用诸如 ...
Object* obj = [[Object alloc] initWithSeparator:NSLineSeparatorCharacter];
... 或 ...
Object* obj = [[Object alloc] initWithSeparator:NSParagraphSeparatorCharacter];
Apples 字符串编程指南/段落和换行符没有帮助。
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];
... or ...
Object* obj = [[Object alloc] initWithSeparator:NSParagraphSeparatorCharacter];
Apples String Programming Guide / Paragraphs and Line Breaks was not helpful, though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确的参数类型是 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