nsstring

UIImage to byte array

安稳与你 提交于 2019-12-01 17:16:53
问题 I'm creating an app that uploads an image to a server. It must send the byte array on a XML. How do I get the byte array into a NSString? Thanks! 回答1: You can convert the UIImage to a NSData object and then extract the byte array from there. Here is some sample code: UIImage *image = [UIImage imageNamed:@"image.png"]; NSString *byteArray = [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; If you are using a PNG Image you can use the

Separate 1 NSString into two NSStrings by whiteSpace

安稳与你 提交于 2019-12-01 17:16:35
问题 I have an NSString which initially looked like <a href="http://link.com"> LinkName</a> . I removed the html tags and now have an NSString that looks like http://Link.com SiteName how can I separate the two into different NSString s so I would have http://Link.com and SiteName I specifically want to show the SiteName in a label and just use the http://Link.com to open in a UIWebView but I can't when it is all one string. Any suggestions or help is greatly appreciated. 回答1: NSString *s = @"http

objective-c concatenate NSString

ぐ巨炮叔叔 提交于 2019-12-01 17:02:50
I have problems to concatenate NSString. Each time I pushed a button I want that something ("aux") is added to my string ("myString"). so: NSString *aux = [NSString stringWithFormat: @"%d", buttonIndex]; myString=[NSString stringWithFormat:@"%@/%@",posTargetaText,aux]; aux = nil; The first time i pushed the button it works good but the second it doesn't work. Some help please? So you can certainly use stringWithFormat , but why don't you use stringByAppendingString instead, since that's exactly what you want to do? NSString *newString = [firstString stringByAppendingString:secondString]; You

NSString nslog revealing “\\n” newline character

五迷三道 提交于 2019-12-01 16:04:51
I want to log an NSString but when I log it, it doesn't show the new line character " n". How can I make it so it does? Thanks. You can process the string first and replace all occurrences of \n with \\n NSString *newString = [originalString stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; 来源: https://stackoverflow.com/questions/6052073/nsstring-nslog-revealing-n-newline-character

XMPP详解

跟風遠走 提交于 2019-12-01 15:43:34
https://www.jianshu.com/p/84d15683b61e https://www.cnblogs.com/lurenq/p/7026983.html 1. xmpp简介 XMPP 是一组基于 XML 的技术。用于实时应用程序。最初。XMPP 作为一个框架开发。目标是支持企业环境内的即时消息传递和联机状态应用程序。 详细简介 xmpp客户端: iOS端: 单聊:xmpp单聊是基于服务器端好友设置来进行聊天的,类似于微信,你可以添加好友,经过同意以后就可以进行聊天。 群聊: xmpp 群聊类似于聊天室的类型,你可以创建一个房间,可以邀请其他人加入这个房间,也可以主动加入群,当房间里面大于等于两个人,就可以进行群聊。不过跟微信不同的是,用户在退出这个聊天,性质就跟退出这个群。如果下次再进入这个群,需要在加入这个群,这样会通过传给服务器的最后一次登录时间,服务器会把这个时间段以后的消息,全部推送给你。 xmpp服务器: Openfire + Spark 简介:下载地址及简单介绍: openfire + Spark这边服务器端了解不多,只是知道通过下载这个应用,通过配置来创建好友和创建房间,进行简单的单聊群聊。如果做服务器的话,肯定不止这么少东西,如果要学习的话还是自己查资料吧。 Openfire下载地址 Openfire + Saprk 简单介绍 2. xmpp聊天原理

Hash value of String that would be stable across iOS releases?

此生再无相见时 提交于 2019-12-01 15:19:41
In documentation String.hash for iOS it says: You should not rely on this property having the same hash value across releases of OS X. (strange why they speak of OS X in iOS documentation) Well, I need a hasshing function that will not change with iOS releases. It can be simple I do not need anything like SHA. Is there some library for that? There is another question about this here but the accepted (and only) answer there simply states that we should respect the note in documentation. Here is a non-crypto hash, for Swift 3: func strHash(_ str: String) -> UInt64 { var result = UInt64 (5381)

How to get NSString size when NSString includes emojis?

青春壹個敷衍的年華 提交于 2019-12-01 15:19:18
问题 I am currently using - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode to get the size of an NSString. However, when that string includes emojis, it seems to calculate the size for the literal unicode character rather than taking into account the size of the emoji itself, rendering the returned size incorrect. How do I correctly get the size of the string with emoji characters, as it will appear in a uilabel? 回答1: The NSString is

NSString nslog revealing “\n” newline character

对着背影说爱祢 提交于 2019-12-01 15:10:59
问题 I want to log an NSString but when I log it, it doesn't show the new line character " n". How can I make it so it does? Thanks. 回答1: You can process the string first and replace all occurrences of \n with \\n NSString *newString = [originalString stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; 来源: https://stackoverflow.com/questions/6052073/nsstring-nslog-revealing-n-newline-character

Does Core Data impose limits on the length of strings?

☆樱花仙子☆ 提交于 2019-12-01 15:03:38
问题 I was wondering if there are any limits on the length of strings stored using Core Data in iOS. (other than available RAM or disk space on the device) 回答1: I think you're more likely to hit the performance limits on an iOS device before you hit any storage limits in Core Data. You'll also be getting a performance hit from pulling in large chunks of data. You are better off, both in performance and manageability, breaking up large blocks of text into smaller chunks. From what I remember Marcus

Replace characters (unique then wildcard value) in a string with other characters

家住魔仙堡 提交于 2019-12-01 14:46:17
I have an NSString, let's say "H,L,K,P" how can I detect a specific character than then a wild-car character... for example, checking for ",*" would return ",L" ",K" and ",P" because they all have the specific "," and then they all have a character after them. Then I want to replace that string with itself plus a "period" appended to it. So "H,L,K,P" would become "H,L.,K.,P." Use a regular expression. The search pattern would be: ,(.) the replacement pattern would be: ,$1. Sample code: NSString *string = @"H,L,K,P"; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern