nsstring

Replace a char into NSString

Hi all! I want simply replace all occourrencies of "+" with a blank " " char... I tried some sample listed here, also used NSSMutableString, but the program crash... what's the best way to replace a char from another?? thanks ...

stringByAddingPercentEscapesUsingEncoding not working with NSStrings with ' 0'

Hi ! I have been having some problem with the stringByAddingPercentEscapesUsingEncoding: method. Here's what happens: When I try to use the method to convert the NSString: "..City=Cl&PostalCode=Rh6 0Nt" I get this this.. "City=Cl&PostalCode=Rh62t" It should be: "..City=Cl&PostalCode=Rh6%200Nt" What can I do about this? Thanks ...

Returning NSString, Error Message: Variable is not CFString

Hi all, i shortly started Programming Mac OS X Applications with Cocoa, so its a realy New bee question. Sorry about this. At first my code snippet: - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { Purchaser *actPurchaser = [tableViewDataArray objectAtIndex:row]...

iPhone Application Delegate variable is not being retained

I am having a very odd issue retrieving/retaining a variable in my iPhone application delegate (AppDelegate). Initially, I can step through and see that my values are passed to logfile (the NSString variable in question), but when logfile is retrieved from another class (see the code below), it faults. Here is my AppDelegate.h file: ...

How to NSLog with \n\r\t

Hello ! Every one. In my application I am reading an HTML page to a string. HTML Page contains many tags, new lines & many other characters. <style type="text/css"> h3{ font-weight:bold; line-height:18px; font-family:Arial; font-size:12px; text-align:justify; color:black; ...

Best practice on initializing your NSStrings on the iPhone

xCode's "build and analyze" complains about "s" being possible garbage. Which is the better solution? A, B, or C? NSString *s; // A NSString *s = nil; // B NSString *s = @""; // C if(x == 1) s = @"you picked 1"; if(x == 2) s = @"you picked 2"; if(x == 3) s = @"you picked 3"; ...

Get string from UILabel

how do I set a NSString using a value from a UILabel? so far i have this but it crashes: NSString *theScore =[[NSString alloc]initWithFormat:@"%@",scoreX.text]; scoreX is a UILabel. can anyone help? thanks in advance ...

In Obj-C How to update an existing NSString variable with a new formatted string?

How do i update an existing NSString variable with a new formatted string? for example i have a variable like this: String1 = [NSString new]; I want this string object to be updated from time to time with new formatted contents using the standard printf format. I can initialise a new NSString using the initWithFormat: message but th...

Efficient use of NSNumberFormatter related to NSString Categories

Hi All, I'm writing an NSString category that requires an NSNumberFormatter. I'm stuck between initing and releasing one every time my category is used to print a string in a certain way or initing the formatter in my app and passing it through. The NSNumberFormatter has a couple of config calls run on it first to make it work just ri...

Turn NSString into integer

Sorry guys, I'm a noob. I know that some languages support type casting, but when I tried to do that here it failed, miserably. I've got an UITextField with number only pad, so I'm only getting numbers, and I need the output from that in my int, diff. Here's what I tried: NSString *outputNumber = [NSString stringWithFormat:@"%d", [textB...

Problem with Tiny URL

Hi Guys! I am developing Twitter API to my application. In my app, I want to display the tiny url with parsed xml link in UITexField as dynamically. statically, I could able to display tiny url in UITextField, but dynamically I am not able to display the tiny url. Please help me! Code: statically(Working fine), NSURL *url = [NSURL UR...

How to get the string value from a string which contains "," ?

I have a string value where it contains comma. Ex:- 1,234. I want to get the value of the string where i need only 1234. Can you please help me... ...

Splitting an NSString

I have the following code which fetches a string from an array of strings and splits the string into 2 parts. NSString *temp = [tableViewData objectAtIndex:indexPath.row]; NSArray *tempArray = [temp componentsSeparatedByString: @"_"]; cell.textLabel.text = [tempArray objectAtIndex:1]; and the String which is added is as follows newTi...

Problem when converting NSString to NSNumber in iPhone

Hey I am having problem when converting string (YaxisData) to NSNumber. I have to return a NSNumber for Core-plot to get the graph done but its not working. Here's the sample code -(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index{ NSNumber *num = [NSNumber numberWithDouble:[[YaxisData...

Objective c constantly checking variable values

I need to have a loop that can constantly check for this variable: NSString *charlieSoundVolume; charlieSoundVolume = [charlieSoundLevel stringValue]; This variable will change by an interface builder patch. I was thinking of doing this: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { while(1) { float fl...

Array in Objective C (iPhone)

Hello, I want to ask about the NSArray in objective C. I want to create a dynamic array as I don't know about the size of the array. And I also want to insert some of the data to the array. However, I don't know how to decl, init and insert the element in to the array. The following is the C++ version. I want to create a empty array A...

What is the better way of handling temporary strings?

I have a situation where I need to use some strings temporarily but I've read so many conflicting things that I'm a bit confused as to what the best way to proceed is. I need to assign some strings inside an if structure but use them outside the if structure so they need to be created outside the if, I was thinking something like: NSSt...

NSTextView Insert Line Break

Hi Folks! I have an NSTextView that I need to insert a line break in. The code looks like this: NSString *myString = @"test" [myTextView insertText:myString]; /**** INSERT LINE BREAK HERE ****/ [[myTextView textStorage] insertAttributedString:MY_ATTRIBUTED_STRING atIndex:myString.length]; Anybody have any idea how to do this? ...

NSString's character reference.

I want to convert the NSString that have character reference (&amp; &apos; etc..). ex. before: &quot;I&apos;m happy.&quot; after: "I'm happy." ...

NSScanner to separate sentence into words (Objective C)

I have a string "So: lets make some noise!" and I would like it to be displayed one word at a time on the screen. How can I go about this? NSScanners? I am new to objective C and really need some help... thank you! for example. the first word i see is "So:" the second word i see is "Lets"...with the last word being "noise!" It must be c...