nsstring

How to get number in NSString(with both numbers and characters)?

给你一囗甜甜゛ 提交于 2019-12-25 01:18:43
问题 I fetch the data from site into NSString like this: <td><font color=#ffffff>35</td> <td><font color=#ffffff>0</td> <td><font color=#ffffff>0</td> <td><font color=#ffffff>0</td> <td><font color=#ffffff>1</td> <td><font color=#ffffff>2</td> <td><font color=#ffffff>0</td> <td><font color=#ffffff>1</td> <td><font color=#ffffff>16</td> <td><font color=#ffffff>45.2</td> <td><font color=#ffffff>3.153</td> and I want to convert into NSArray with numbers only. I have been tried many classed and

What is __CFString?

梦想与她 提交于 2019-12-25 01:08:17
问题 I have arg1 which is an IMessage. IMessage is defined as: struct IMessage { ... struct CFString _field2; ... }; and CFString is defined as: struct CFString { void **_vptr$CFObject; struct __CFString *mCFRef; _Bool mIsMutable; }; and __CFString is defined as: struct __CFString; My goal is to get a string of some sort be it NSString or CFStringRef from arg1, so how can i do it? Thanks. Here is the error I get when I try to nslog mCFRef: Thread 0 crashed: # 1 0x97b41edb in _objc_msgSend +

Pass NSString from one class to another

纵饮孤独 提交于 2019-12-25 00:16:50
问题 I have some weird issue here as somehow I am unable to pass NSString from one class to another. I deployed the same method that worked on other classes. I am trying to pass a string from secondViewController to my firstViewController. Here's what I did. firstViewController.h NSString *pickUpAddressString; @property (nonatomic, retain) NSString *pickUpAddressString; firstViewController.m @synthesize pickUpAddressString; -(void) viewWillAppear:(BOOL)animated { NSLog(@"pickUpAddressString is %@"

How to convert an NSString to char

淺唱寂寞╮ 提交于 2019-12-24 21:45:37
问题 I am trying to convert an NSString to a ResType , as defined below in MacTypes.h . FourCharCode // A 32-bit value made by packing four 1 byte characters together typedef FourCharCode ResType; I think I could use [aString getCharacters:range:] , but is there a more straight forward way to make this conversion? After trying suggestions from David, here is some further information. I am using GTResourceFork, a Cocoa wrapper for accessing resource forks. The method I am calling is: - (NSArray *

NSString special characters encoding

断了今生、忘了曾经 提交于 2019-12-24 21:32:21
问题 Im trying to convert some special characters like ä , ö , ü , α , μ , α , ο , ι , and others from a webpage. When I download the page with the ASIHTTPRequest i get some codes instead of the character itself. Examples: ä = \u00E4 μ = \u03BC α = \u03B1 This also happens if I use [NSString stringWithContentsOfURL:aNSURL encoding:NSASCIIStringEncoding error:nil]; I have tried different encodings available but none of them work for the above example. For example: With the NSUnicodeStringEncoding I

How to unescape backslashes on macOS?

。_饼干妹妹 提交于 2019-12-24 18:43:32
问题 Localized.strings files may contain escaped chars like \n and \" . How do I efficiently unescape them? I know I could write my own function that looks for a \ and removes it and then keeps searching at the second-next character (so that I don't turn \\ into nothing), but that won't handle special escape methods such as an octal character numbers (e.g. \012 for a LF) and possibly other forms. I'd think that NSString would offer a function for that but I can't find any. Actually, this appears

How do I convert a hex color in an NSString to three separate rgb ints in Objective C?

你。 提交于 2019-12-24 16:13:29
问题 I may be making something incredibly simple incredibly complicated, but nothing I've tried so far seems to work. I have NSStrings like @"BD8F60" and I would like to turn them into ints like: r = 189, g = 143, b = 96. Have found ways to convert hex values that are already ints into rgb ints, but am stuck on how to change the NSString with the letters in it into an int where the letters have been converted to their numerical counterparts. Apologize in advance if this is incredibly basic--I'm

Find substring range of NSString with unicode characters

放肆的年华 提交于 2019-12-24 12:45:36
问题 If I have a string like this. NSString *string = @"😀1😀3😀5😀7😀" To get a substring like @"3😀5" you have to account for the fact the smiley face character take two bytes. NSString *substring = [string substringWithRange:NSMakeRange(5, 4)]; Is there a way to get the same substring by using the actual character index so NSMakeRange(3, 3) in this case? 回答1: Make a swift extension of NSString and use new swift String struct. Has a beautifull String.Index that uses glyphs for counting characters and

How to get count of Unique chars in a string

江枫思渺然 提交于 2019-12-24 12:05:04
问题 How can I get the number of unique chars in my String? Ex: NSString *myString = @"Hello"; I want the count to be 4 and not 5. I was trying to use the NSCharacterSet of myString and get the count but seems like it doesnt work. NSCharacterSet *myCharSet = [NSCharacterSet characterSetWithCharactersInString:myString]; [myCharSet count]; Thanks for the tip. 回答1: A derivative of your code: NSCharacterSet *myCharSet = [NSCharacterSet characterSetWithCharactersInString:@"Hello"]; NSLog(@"Character

Convert NSString to NSDictionary separated by specific character

久未见 提交于 2019-12-24 12:03:05
问题 I need to convert this "5?8?519223cef9cee4df999436c5e8f3e96a?EVAL_TIME?60?2013-03-21" string into dictionary. Separated by "?" Dictionary would be some thing like { sometext1 = "5", sometext2 = "8", sometext3 = "519223cef9cee4df999436c5e8f3e96a", sometext4 = "EVAL_TIME", sometext5 = "60", sometext6 = "2013-03-21" } Thank you . 回答1: Break the string to smaller strings and loop for them. This is the way NSArray *objects = [inputString componentsSeparatedByString:@"?"]; NSMutableDictionary *dict