Questions tagged [nsmutablestring]

The NSMutableString class declares the programmatic interface to an object that manages a mutable string — that is, a string whose contents can be edited — that conceptually represents an array of Unicode characters.

To construct and manage an immutable string — or a string that cannot be changed after it has been created — use an object of the NSString class.

The NSMutableString () class adds one primitive method

-replaceCharactersInRange:withString:

to the basic string-handling behavior inherited from NSString . All other methods that modify a string work through this method.

More information : NSMutableString Class reference

306 questions
4
votes
3 answers

Change text of an attributed string and retain attributes in Swift

For output in a database program, I have certain text that I've inserted marks to indicate bold or italics, as well as some text that is substituted for images. For instance: "%Important% ^All employees to the breakroom^" should have final output…
Dan M
  • 91
  • 1
  • 5
4
votes
2 answers

Appending a String to NSMutableString in Swift

I found answers to my question in Objective C but couldnt find it in Swift. How can I make the code below work in terms of adding a String value to an NSMutableString? It throws "length only defined for abstract class" error. This code is aimed to…
johncoffey
  • 251
  • 3
  • 12
4
votes
4 answers

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

How do I trim " " and "\n" in NSMutableString?
marcy
  • 4,213
  • 3
  • 23
  • 14
4
votes
1 answer

NSMutableString replaceOccurrencesOfString replacing whole words

Is there a way to use replaceOccurrencesOfString (from NSMutableString) to replace whole words? For example, if I want to replace all occurrences of a fraction in a string, like "1/2", I'd like that to match only that specific fraction. So if I had…
abellina
  • 1,016
  • 1
  • 11
  • 27
4
votes
3 answers

How to insert a NSString into a NSMutableString?

I have a NSMutableString where i need to insert another NSString at two places. My NSMutableString is NSMutableString *webServiceLinkWithResponses = [[NSMutableString alloc]…
Pradeep Reddy Kypa
  • 3,992
  • 7
  • 57
  • 75
3
votes
1 answer

Bad Access when trying to access a Mutable Array with an NSMutableString

I synthesized an NSMutableArray called email, which is part of an object Person. The email array contains pointers to several NSMutableString objects. @property (strong) NSMutableArray *email; @synthesize email = _email; The string was declared (in…
Carelinkz
  • 936
  • 8
  • 27
3
votes
2 answers

Quick way to jumble the order of an NSString?

Does anyone know of an existing way to change the order of an existing NSString or NSMutableString's characters? I have a workaround in mind anyway but it would be great if there was an existing method for it. For example, given the string @"HORSE",…
Bob-ob
  • 1,560
  • 4
  • 18
  • 34
3
votes
3 answers

How to remove the last character from an NSMutableString

Iam adding some text content to nsmutablestring in the form of dictionary format and again that every dictionary is split by ","(commos). But when getting this total string its displays (,) to string of ending. So how to remove that ","(commos) in…
Nari
  • 213
  • 5
  • 16
3
votes
2 answers

What's the best way to generate this string? (NSMutableString...)

I have a dictionary whose keys are NSStrings and whose objects are NSArray. Here's an example: key (NSString) : GroupA value (NSArray): John Alex Joe Bob There are many entries like this, this is…
user635064
  • 6,219
  • 12
  • 54
  • 100
3
votes
3 answers

error : 'Attempt to mutate immutable object with appendString:' --

I am getting an error 'Attempt to mutate immutable object with appendString:' and my code is NSMutableString *resultString= [[NSMutableString alloc]init]; for (NSMutableString *s in self.ArrayValue) { [resultString appendString:s]; …
Pooja
  • 2,162
  • 5
  • 33
  • 64
3
votes
1 answer

Can we compare the NSString with NSMutableString

for example... NSString string1 = @"Hello world"; NSMutableString string2 = [NSMutableString stringWithString: string1]; then... then can we compare these using following statement..? or there is any other way? if(string1…
rockey
  • 638
  • 4
  • 16
  • 34
3
votes
1 answer

How to replace string occur in NSMutableString from another string

I have a NSMutableString that contains a word twice.(e.g. /abc ...................... /abc). Now I want to replace these two occurrences of /abc with /xyz. I want to replace only first and last occurence no other occurences. -…
Greshi Gupta
  • 831
  • 2
  • 10
  • 16
3
votes
3 answers

NSMutableString appendString generates a SIGABRT

This makes no sense to me. Maybe someone here can explain why this happens. I've got an NSMutableString that I alloc at the top of my iPhone app, then append to later in the process. It results in a SIGABRT, which doesn't add up to me. Here's the…
Axeva
  • 4,697
  • 6
  • 40
  • 64
3
votes
4 answers

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 = @"

header

"; pageData = [pageData stringByAppendingFormat@"

"]; pageData =…

Frames1984
  • 31
  • 2
3
votes
2 answers

Cocoa: NSMutableString binding to XIB does not update, but NSString binding does update

A label in a XIB bound to an NSMutableString property does not seem to update when I change the string, but the label does update if the property is NSString. In a test app, I have the default AppDelegate class and MainMenu.xib. I create two…
matlabGuy
  • 31
  • 2
1 2
3
20 21