nsstring

Replace characters in C string

半世苍凉 提交于 2019-12-12 02:47:06
问题 Given this C string: unsigned char *temp = (unsigned char *)[@"Hey, I am some usual CString" UTF8String] How can I replace "usual" with "other" to get: "Hey, I am some other CString". I cannot use NSString functions ( replaceCharactersInRange / replaceOccurencesOfString , etc.) for performance reasons. I have to keep it all at low level, since the strings I'll be dealing with happen to exceed 5MB, and therefore the replacements (there will be a lot of replacements to do) take about 10 minutes

How to get the values of selected cells of a UITableView in one string

£可爱£侵袭症+ 提交于 2019-12-12 02:46:51
问题 i'm pretty sure this is really simple. But i can't get to make this work. I have a UITableView where i display dynamically a list of facebook friends, thanks to their FBID. Basically, i would like to return the FBIDs of the friends i selected, in one string separated with commas. If possible, in a IBAction, so i can pass them into parameters of a php. For example, let's pretend i have a list of 4 friends, A B C D, and their ids are 1,2,3,4. If i select A and C, i would like to have a string

Converting NSString to NSData without changing data

旧街凉风 提交于 2019-12-12 02:45:03
问题 I have an NSString that contains a series of hex values, for example: 6173736e 616d65a2 15165570 6f696e74 584e534f 626a6563 However, I need this exact same data to be in an NSData object. I have tried doing things such as: mydata = [mystring dataUsingEncoding:NSASCIIStringEncoding]; //have tried all kind of encoding options Regardless of what I do though, mydata never contains the same values the NSString had, which is what I need. Would greatly appreciate any help! Thank you. 回答1: You seem

Replace string in between occurrences

喜欢而已 提交于 2019-12-12 02:09:34
问题 I have a string I want to display inside the uiwebview that may look like this: "blah blah blah [IMG]you.png[/IMG] blah blah [IMG]me.png[/IMG]" I want it replaced like this: "blah blah blah <img src=\"you.png\"> blah blah <img src=\"me.png\">" I can already get the string between the [IMG]...[/IMG] the problem is that it can only get the first set of [IMG]...[/IMG] and the rest of the occurrence cannot. NSRange startRange = [finalQuestionString rangeOfString:@"[IMG]"]; if (startRange.location

NSDate from NSString , shows the previous day

ぃ、小莉子 提交于 2019-12-12 02:03:13
问题 I have s imple NSDate from NSString as below NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd"]; issueDatabase.album_date = [dateFormatter dateFromString:albumXML.album_date]; but for some reason I'm getting the previous day instead of the current for eample if my albumXML.album_date is equal 2011-09-01 I'm getting the following stored in my database 2011-08-31 回答1: You need to set a timezone to your dateFormatter: [dateFormatter

writing NSString type to a file

风流意气都作罢 提交于 2019-12-12 01:57:47
问题 I'm implementing the following function on appdelegate , but I need to write NSString type instead of typical float values. Since xcode doesn't allow an object to be in my desired position, I used char* instead as follows, where as my data to be passed are of type NSString . As expected, it doesn't work... How could I manipulate it so that I could write NSString data type? Should I make some conversion? Please help me out.. - (void)addHallOfFamer:(char*)newHofer{ [hofArray addObject:[NSString

Get unichar * from a C++ std::string& to create a nonnull NSString in Objective-C++

亡梦爱人 提交于 2019-12-12 01:45:56
问题 I have some Objective-C++ that wraps an existing C++ library. The C++ library occasionally gives me std::string& parameters that I want to convert into nonnull NSString s. Almost all of the NSString initializers return nullable NSString s except: -initWithCharactersNoCopy:length:freeWhenDone: and -initWithCharacters:length: . However, both of those require unichar * , but std::string.c_str() returns char * . How can I get a unichar * from a C++ std::string so that I can create an NSString *

NSString MD5 with hash

回眸只為那壹抹淺笑 提交于 2019-12-12 01:45:52
问题 Hi have to perform a login via web service sending username and password. The problem is that the server wants a strange MD5 format of password and I can't generate it. Example NSString password = @"."; NSString md5 = @"5058f1af8388633f609cadb75a75dc9d"; Server MD5 is "PXñ¯ƒˆc?`œ­·ZuÜ" . I need to transform 5058f1af8388633f609cadb75a75dc9d in "PXñ¯ƒˆc?`œ­·ZuÜ" , but I have no ideas. Edit I've discovered that the result is an hash of 5058f1af8388633f609cadb75a75dc9d string.This is the .NET

Word output based on NSString sequences

做~自己de王妃 提交于 2019-12-12 01:26:35
问题 What I want to do is take 3 letter word sequences from an NSString, and change them in to corresponding words. EX) AUG = "START", AGC = "Asparagine", etc. My thought was to change the NSString in to an NSArray with each element containing 3 letters, where I can then reference them in a for loop, to make a new string with the Resulting words. Example: NSDictionary *aminoReplaceDict = @{ @"AAA" : @"Lysine", @"AAC" : @"Asparagine", @"AAG" : @"Lysine", @"AAU" : @"Asparagine", @"ACA" : @"Threonine

Turning numbers into uppercase numbers with NSAttributedString/NSString and UILabel

巧了我就是萌 提交于 2019-12-12 00:19:40
问题 I'm using a font here that has different looks for uppercase and lowercase numbers. This works perfectly in text editors, and Adobe's tools (by settings labels to uppercase only), and I figured this would work in UIKit as well by just running the string through the uppercaseString method, but it doesn't seem to actually turn the numbers into their uppercase versions. So… How can I turn numbers into uppercase in UIKit? Can I? 回答1: This blog post may help. Also note that while there are quite a