nsstring

String comparison for localization

梦想的初衷 提交于 2019-12-05 00:09:45
问题 What is the difference between NSString 's localizedCaseInsensitiveCompare: and localizedStandardCompare: methods? I read the reference but did not get a proper idea of which one to use. 回答1: localizedCaseInsensitiveCompare: is equivalent to: [aString compare:otherString options:NSCaseInsensitiveSearch range:NSMakeRange(0,aString.length) locale:[NSLocale currentLocale]]; localizedStandardCompare: is basically equivalent to: [aString compare:otherString options:NSCaseInsensitiveSearch |

How to convert a string to float? [duplicate]

假如想象 提交于 2019-12-05 00:09:20
This question already has answers here : Closed 8 years ago . Possible Duplicate: Convert string to float in Objective-C I'd like to convert a string to a float. /* dict is an NSDictionary to load Preferences */ NSString *str = [dict objectForKey:@"key"]; This is where I got. Now I'd like to convert the string value (in this case @"32.0f" ) in a float, where it could be processed by my application. How can I do this? CGFloat strFloat = (CGFloat)[str floatValue]; Just pass the message floatValue to the NSString object. NSString::floatValue 来源: https://stackoverflow.com/questions/6240601/how-to

Global NSString

梦想的初衷 提交于 2019-12-04 22:51:15
问题 I need to create an NSString, so I can set its value in one class and get it in another. How can I do it? 回答1: if you write: NSString *globalString = @"someString"; anywhere outside a method, class definition, function, etc... it will be able to be referenced anywhere. (it is global!) The file that accesses it will declare it as external extern NSString *globalString; This declaration signifies that it is being accessed from another file. 回答2: Make it a global variable. In one file in global

Using NSScanner to parse a string

廉价感情. 提交于 2019-12-04 22:35:31
问题 I have a string with formatting tags in it, such as There are {adults} adults, and {children} children . I have a dictionary which has "adults" and "children" as keys, and I need to look up the value and replace the macros with that value. This is fully dynamic; the keys could be anything (so I can't hardcode a stringByReplacingString ). In the past, I've done similar things before just by looping through a mutable string, and searching for the characters; removing what I've already searched

how to convert this string to json or dictionary in ios

可紊 提交于 2019-12-04 22:07:26
I tired with links but those are not working in my case. Can anyone suggest me on how to convert this string to json or dictionary. This string is having a dictionary with an array of strings. NSString *temp=@"{\n name = {\n dob = \"\";\n age = \"61\";\n family = (\n {\n location = location;\n mobile = mobile;\n }\n );\n };\n}"; Here family is an array. I got the solution. First I tried your code NSString *temp=@"{\n name = {\n dob = \"\";\n age = \"61\";\n family = (\n {\n location = location;\n mobile = mobile;\n }\n );\n };\n}"; My out put result is null Then I changed the JSON format. So

How to find matching words in two separate strings?

断了今生、忘了曾经 提交于 2019-12-04 21:28:38
If there are two separate strings, we need to retrieve all words that are matching (in those strings), in an array. also this matching should be case insensitive. What will be the most efficient way to achieve this. For Example: NSString *s1 = @"Hello there, I want to match similar words."; NSString *s2 = @"Do you really want to match word, hello?"; The resulting array should contain, "hello", "want", "to", "match" . I went through many questions and, responses over the net like Regular expression to match a line that doesn't contain a word? , but didn't, find solution needed. You can use

Superscripted ordinal suffix in NSString

被刻印的时光 ゝ 提交于 2019-12-04 21:02:11
Is there a way in NSString to output the st, nd, and rd but in a superscripted format? Any known unicode perhaps? Josh Caswell There doesn't seem to be any Unicode characters for this, but it's easy enough to make an NSAttributedString that will do the trick: NSDictionary * superscriptAttrs = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:1] forKey:NSSuperscriptAttributeName]; NSAttributedString * st = [[NSAttributedString alloc] initWithString:@"st" attributes:superscriptAttrs]; NSMutableAttributedString * premiere = [[NSMutableAttributedString alloc] initWithString:@"1"];

iPhone dev: Replace uppercase characters in NSString with space and downcase

不想你离开。 提交于 2019-12-04 20:35:49
I have: NSString *promise = @"thereAreOtherWorldsThanThese"; which I'm trying to transform into the string: @"There are other worlds than these" I'm guessing this is a regex job, but I'm very new to Objective C, and have so far had no luck. I would greatly appreciate any help! Thomas Joulin I'd use GTMRegex ( http://code.google.com/p/google-toolbox-for-mac/ ), for example: NSString *promise = @"thereAreOtherWorldsThanThese"; GTMRegex *regex = [GTMRegex regexWithPattern:@"([A-Z])"]; NSLog(@"%@", [[regex stringByReplacingMatchesInString:promise withReplacement:@" \\1"] lowercaseString]); As for

Autocompletion using UITextView should change text in range

跟風遠走 提交于 2019-12-04 19:36:01
I followed Ray Wenderlich's tutorial on text autocompletion here: http://www.raywenderlich.com/336/how-to-auto-complete-with-custom-values And it works great, but it only allows searching for a string that is contained in the textView. I need it to search for multiple strings in the same view. For example: Hi @user, how's @steve Should search for both occurrences of the @. Here is the original code: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { autocompleteTableView.hidden = NO; NSString *substring = [NSString

使用Reveal分析任意的界面结构

霸气de小男生 提交于 2019-12-04 19:19:04
更新时间:2016.1.27 已支持直接在Cydia中下载插件Reveal Loader 来监控任意app的UI了 特别提醒,现已无需按下面的方式注入libReveal.dlib了,只需把libReveal.dylib上传到设备的/Library/MobileSubstrate/DynamicLibraries,然后同时编辑并上传一个libReveal.plist,格式如下: 图3 设定BundleID 注意,此时是可以指定多个BundleID的,也就是说,你可以同时监控任意多的app;再扩大一步说,如果你愿意,不上传这个libReveal.plist,你可以监控所有app,只要你不觉得机器很慢。。。 一定确保手机和电脑端处在同一局域网中,不然看不到界面的 Reveal.app 目前能搞到2.0.3的版本且能用注册机破解,但貌似对ios7.0以上的应用无效,需要Reveal2.0.4版,但又无法破解目前,2.0.3版本百度云下载 http://c.blog.sina.com.cn/profile.php?blogid=cb8a22ea89000gtw&qq-pf-to=pcqq.c2c 打开XCode创建iOSOpenDev--》Logos Tweak的工程 创建动态加载Reveal的类RevealUtil: // // RevealUtil.h // pyu // //