nsmutablestring

Categories for NSMutableString and NSString causing binding confusion?

Hi, I have extended both NSString and NSMutableString with some convenience methods using categories. These added methods have the same name, but have different implementations. For e.g., I have implemented the ruby "strip" function that removes space characters at the endpoints for both but for NSString it returns a new string, and fo...

Defining NSMutableString?

My understanding is that both of these create a NSMutableString, only the first one is owned by the system and the second one is owned by me (i.e. I need to release it). Is there any particular reason why I should use one or the other, on the face of it it seems easier to use the first? Also is the first better as it gives the compiler a...

How do I trim " " and "\n" in NSMutableString.

Objective-C:: How do I trim " " and "\n" in NSMutableString. ...

How to return correctly a NSMutableString from a method

Hi, I'm looking for a good way to return a string constructed by a NSMutableString avoiding leaking : eg: +(NSString *)myMethod{ NSMutableString *numberToReturn = [[NSMutableString alloc] init]; [numberToReturn appendString:@"lorem ipsum"]; return numberToReturn; } The leak instrument said I had leak with this variable. I t...

How add data from NSMutableString into NSArray?

hi, is it an possible to add a value from an NSMutableString into an NSArray? Whats the snippet? ...

Cocoa: NSMutableString gives warning with stringValue

This works: NSString *myVar = @"whatever"; NSDecimalNumber *myNum = [NSDecimalNumber decimalNumberWithString:@"10"]; myVar = [myNum stringValue]; This version with mutable string produces warning "assignment from distinct Objective-C type": NSMutableString *myVar = [NSMutableString stringWithString:@"whatever"]; //UPDATE: CORRECT...

Cannot strip newline from Cocoa NSMutableString ...

Hey, for the life of me, this is not working:.. NSMutableString *b64String = [[[NSMutableString alloc] initWithFormat:@"Basic %@", [string _base64Encoding:string]] autorelease]; [b64String stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; NSLog(@"(%@)", b64String); NSRange foundRange = [b64String r...

How to display currency without rounding as string in Xcode?

Hello everyone, I have trouble when I have currency value 999999999999999999.99 From that value, I want to display it as String. The problem is that value always rounded to 1000000000000000000.00 I'm not expect that value rounded. I want the original value displayed. Do you have any idea how to solve this problem? I tried this code f...

NSArray question - \n\t\t being added to the end of strings?

My strings are fine, but when they get added to an array a weird grouping of "\n\t\t" gets added to the end. So the string "Apple", becomes "Apple\n\t\t" when I look at the array description. Whats the deal with that? and how do I fix it? Addition: Its XML code. It seemed like [currentPlace appendString:string]; would get the right pa...

Sensitive data: NSString VS NSMutableString (iPhone)

I have some sensitive data I want to clear directly after use. Currently, the sensitive data is in the form of NSString. NSString is in my understanding immutable, meaning that I can't really clear the data. NSMutableString seems more appropriate, though, as it is mutable and has methods like replaceCharactersInRange and deleteCharacters...

Set Limit and clear in nsmutableString

I need to limit the number of characters that can be appended to an nsmutablestring to 10. Also i need to clear its contents on a button press. What is the best method to do that? pls help ...

Position of a character in a NSString or NSMutableString

Hello, I have searched for hours now and haven't found a solution for my problem. I have a NSString which looks like the following: "spacer": ["value1", "value2"], "spacer": ["value1", "value2"], ... What I want to do is to remove the [ ] characters from the string. It's seems to be impossible with objective-c. Most other programming...

NSString or NSMutableString category for templating

Is anyone aware of a category on NSString or NSMutableString that allows for templating? I'd like to create a template and use tags for variables, then "apply" a KVC-compliant object against the string to have the variables replaced. Or another way of asking... How is templating currently done in the iPhone / Objective-C universe? Is ...

NSMutable String "Out of scope"

I have two NSMutableString objects defined in my viewController's (a subclass of UITableViewController) .h file: NSMutableString *firstName; NSMutableString *lastName; They are properties: @property (nonatomic, retain) NSMutableString *firstName; @property (nonatomic, retain) NSMutableString *lastName; I synthesis them in the .m fi...

Appending Strings to NSMutableString

Been looking at this for a bit now and not understanding why this simple bit of code is throwing an error. Shortened for brevity: NSMutableString *output; ... @property (nonatomic, retain) NSMutableString *output; ... @synthesize output; ... // logs "output start" as expected output = [NSMutableString stringWithCapacity:0]; [outpu...

How do I send the mutable string to the NSTextField properly?

So I have all this code that I have debugged and it seems to be fine. I made a mutable string and for some reason I can not get it to be displayed on my label. the debugger says "2010-04-22 22:50:26.126 Fibonacci[24836:10b] * -[NSTextField setString:]: unrecognized selector sent to instance 0x130150" What is wrong with this? When I ju...

Xcode - EXEC_BAD_ACCESS when concatenting a large string.

I'm getting a EXEC_BAD_ACCESS when concatenting a large string. I've read from a feed and to create my webview I build up my string like: NSString *pageData = @"<h1>header</h1>"; pageData = [pageData stringByAppendingFormat@"<p>"]; pageData = [pageData stringByAppendingFormat@"self.bodyText"]; pageData = [pageData stringByAppendingFor...

How do I convert an NSMutableString to NSString when using Frameworks?

I have written an Objective-C framework which builds some HTML code with NSMutableString which returns the value as an NSString. I have declared an NSString and NSMutableString in the inteface .h file: NSString *_outputLanguage; // Tests language output NSMutableString *outputBuilder; NSString *output; This is a sample from th...

NSMutableDictionary can't have "time" to read objects (NSMutableString s)

Hi, I'am setting the text of labels with the content of NSMutableString_s which are objects of a NSMutableDictionray ... the problem that all things work fine when i load the page for two times (so i push ,after i pop...) and with the third push the program can't read the content of one of the NSMutableString_s of the NSMutableDictionary...

nsdata to nsstring to nsdata

Hello everybody. I am calling the webservices. The web service returns data in xml format. Now the problem is the xml data is not being received in proper format. In place of "<", ">" it returns in html form . So i assigned the xmldata to a NsMutableString and replaced the escape characters so that the format of xml data is proper. Then ...