nsstring

How do you remove extra empty space in NSString?

和自甴很熟 提交于 2020-01-19 10:08:59
问题 is there a simple way to remove the extra spaces in a string? ie like... NSString *str = @"this string has extra empty spaces"; result should be: NSString *str = @"this string has extra empty spaces"; Thanks! 回答1: replace all double space with a single space until there are no more double spaces in your string. - (NSString *)stripDoubleSpaceFrom:(NSString *)str { while ([str rangeOfString:@" "].location != NSNotFound) { str = [str stringByReplacingOccurrencesOfString:@" " withString:@" "]; }

How do you remove extra empty space in NSString?

梦想与她 提交于 2020-01-19 10:07:50
问题 is there a simple way to remove the extra spaces in a string? ie like... NSString *str = @"this string has extra empty spaces"; result should be: NSString *str = @"this string has extra empty spaces"; Thanks! 回答1: replace all double space with a single space until there are no more double spaces in your string. - (NSString *)stripDoubleSpaceFrom:(NSString *)str { while ([str rangeOfString:@" "].location != NSNotFound) { str = [str stringByReplacingOccurrencesOfString:@" " withString:@" "]; }

iOS NSString 与NSData转化

爱⌒轻易说出口 提交于 2020-01-19 05:27:42
本文转载自: https://www.cnblogs.com/liuting-1204/p/6389318.html 作者:liuting-1204 转载请注明该声明。 1. 字符串转 Data NSString * str = @"str"; NSData *data =[str dataUsingEncoding: NSUTF8StringEncoding]; 2.NSData 转NSString NSString * str =[[ NSString alloc] initWithData:data encoding: NSUTF8StringEncoding]; 3.data 转char NSData *data; char * haha=[data bytes]; 4. char 转data byte * byteData = malloc( sizeof(byte)* 16); NSData *content=[ NSData dataWithBytes:byteData length: 16]; 来源: CSDN 作者: hong2511 链接: https://blog.csdn.net/hong2511/article/details/103746414

Why is this code not recognising the NSString as being equal?

大城市里の小女人 提交于 2020-01-18 18:06:19
问题 This is the code I have: NSLog(@"name: %@", name); NSLog(@"service: %@", service.name); if (name == service.name) { NSLog(@"Test"); } Name is "Andrew’s MacBook Pro". Service is "Andrew’s MacBook Pro" And yet I don't get a "Test" from NSLog. Any ideas why this could be? 回答1: use [string isEqualToString:@"any string"] See a very useful discussion here: Understanding NSString comparison 回答2: For string comparisons, use [name isEqualToString:service.name] Using == will compare to see if both

Why is this code not recognising the NSString as being equal?

时光毁灭记忆、已成空白 提交于 2020-01-18 18:05:35
问题 This is the code I have: NSLog(@"name: %@", name); NSLog(@"service: %@", service.name); if (name == service.name) { NSLog(@"Test"); } Name is "Andrew’s MacBook Pro". Service is "Andrew’s MacBook Pro" And yet I don't get a "Test" from NSLog. Any ideas why this could be? 回答1: use [string isEqualToString:@"any string"] See a very useful discussion here: Understanding NSString comparison 回答2: For string comparisons, use [name isEqualToString:service.name] Using == will compare to see if both

Why is this code not recognising the NSString as being equal?

时光怂恿深爱的人放手 提交于 2020-01-18 18:01:49
问题 This is the code I have: NSLog(@"name: %@", name); NSLog(@"service: %@", service.name); if (name == service.name) { NSLog(@"Test"); } Name is "Andrew’s MacBook Pro". Service is "Andrew’s MacBook Pro" And yet I don't get a "Test" from NSLog. Any ideas why this could be? 回答1: use [string isEqualToString:@"any string"] See a very useful discussion here: Understanding NSString comparison 回答2: For string comparisons, use [name isEqualToString:service.name] Using == will compare to see if both

Why is this code not recognising the NSString as being equal?

时光总嘲笑我的痴心妄想 提交于 2020-01-18 17:59:09
问题 This is the code I have: NSLog(@"name: %@", name); NSLog(@"service: %@", service.name); if (name == service.name) { NSLog(@"Test"); } Name is "Andrew’s MacBook Pro". Service is "Andrew’s MacBook Pro" And yet I don't get a "Test" from NSLog. Any ideas why this could be? 回答1: use [string isEqualToString:@"any string"] See a very useful discussion here: Understanding NSString comparison 回答2: For string comparisons, use [name isEqualToString:service.name] Using == will compare to see if both

即时通讯之环信视频语音实时通话与单聊和群聊实现

戏子无情 提交于 2020-01-17 19:05:00
即时通讯 1. 即时通讯简介 即时通讯英文名为:Instant Messaging,简称IM。 即时通讯(Instant messaging,简称IM)是一个终端服务,允许两人或多人使用网路即时的传递文字讯息、档案、语音与视频交流。即时通讯按使用用途分为企业即时通讯和网站即时通讯,根据装载的对象又可分为手机即时通讯和PC即时通讯,手机即时通讯代表是QQ,微信。 2. 即时通讯的代表作 主流的代表:Skype/QQ/Google Talk/WhatsApp/Instagram/LINE/Kik/Wechat/Facebook Messenger/Yahoo! Messenger/MSN Messenger/ICQ/IChat 3. 如何实现即时通讯 即时通讯实现需要开发者写一个通讯协议,比如服务器的通讯协议是一致的,服务器跟服务器之间进行数据的传输,A客户端和B客户端就能进行数据的传输。 协议:定义一个标准,如何传输数据和客户端如何通讯。 4. iOS中如何实现即时通讯 使用Socket写一个通讯协议( 自己写一个协议 ) 使用 XMPPframework 第三方框架 使用国内第三方框架 融云 使用国内第三框架 环信 使用国内第三方框架 LeanCloud 使用国内第三方框架 阿里悟空 ... 5. 以上几种方式简单分析 各行各业的App使用的通讯框架各有差异

How to use NSLineSeparatorCharacter and NSParagraphSeparatorCharacter?

荒凉一梦 提交于 2020-01-17 05:06:12
问题 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]

iOS special characters, strange issue

允我心安 提交于 2020-01-16 18:18:14
问题 I've got a very strange issue. I started an iOS App about three years ago (iOS-SDK 3.0), and since then went through the SDKs 4.0 and 5.0. Since 5.0 (or maybe 5.1) I suddenly started having problems with German special chars (ä ö ü ß). Now I can't even initialize an NSString with special chars, this line: NSString *str = @"abcäxyz"; gives the following warning: Input conversion stopped due to an input byte that does not belong to the input codeset UTF-8 And this one: NSLog(@"%@", strTemp);