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
3
votes
2 answers

Clear the content of NSMutableString instance

I created an NSMutableString pointer variable and appended some text using the below code in the implementation file. NSMutableString *displayString; [displayString appendString: [NSString stringWithFormat:@"%i", digit]]; However, I would like to…
TeKnofUNk
  • 531
  • 1
  • 7
  • 9
3
votes
2 answers

Assigning NSMutableString from NSString Warning

I have the following three lines of code in my program: NSMutableString *stringOne = [NSMutableString stringWithFormat:@"Hello "]; NSMutableString *stringTwo = [NSMutableString stringWithFormat:@"World"]; NSMutableString *sayIt = [stringOne…
Scooter
  • 4,068
  • 4
  • 32
  • 47
3
votes
5 answers

How add data from NSMutableString into NSArray?

is it an possible to add a value from an NSMutableString into an NSArray? Whats the snippet?
Apache
  • 1,796
  • 9
  • 50
  • 72
3
votes
4 answers

Inserting a comma for integers when there are three digits added everytime to the textfield in iOS

I need to add comma separating numbers into three digits without white spaces and if total digits are under three, then no comma added. For example: 2984 => 2,984 297312984 => 297,312,984 298 => 298 How do I solve this? Tried…
lakshmen
  • 28,346
  • 66
  • 178
  • 276
3
votes
2 answers

What is the recommended way to append to NSString

I am performing some string concatenation to create a database query. As part of this, I need to assign and re-assign NSString variable in order to append to it. I am currently using this code: NSString *retVal = [[NSString alloc]init]; NSString…
Nirav Bhatt
  • 6,940
  • 5
  • 45
  • 89
2
votes
3 answers

Why do I get "Attempt to mutate immutable object with replaceOccurrencesOfString:" when all vars ar Mutable

Pretty simple code, which I may say worked as intended in Xcode 4.1 but breaks in Xcode 4.2. Here is the offending code: -(void)mergeDevData2Email:(NSMutableString *)target codeArray:(NSArray *)array1 valueArray:(NSArray *)array2 { NSUInteger n =…
Ric
  • 796
  • 12
  • 28
2
votes
1 answer

Set newline and paragraph in string with objective C

When i parse the jason url i got string with character \n \r ... Now i want break the line where with "\n" and put the paragraph with "\r". i got string like this. description = "Black Chasm Cavern was designated a National Natural Landmark by the…
Raj
  • 1,213
  • 2
  • 16
  • 34
2
votes
3 answers

Assigning NSMutableString To UILabel Text

I am making a fraction calculator app from the Programming In Objective-C 2.0 book. I am using XCode 4.1 for Lion. I have completely and successfully without any error typed in the code. But when I press a number button while the app is running, the…
user973985
  • 291
  • 2
  • 7
  • 14
2
votes
3 answers

NSString may not respond to append string

I have a NSMutableString and I am trying to use appendString method. Though it works fine but every time I use it, I receive a warning NSString may not respond to append string. This is my code : -(void)parser:(NSXMLParser *)parser…
Nitish
  • 13,845
  • 28
  • 135
  • 263
2
votes
3 answers

How to set the text of a previously-created NSMutableString?

I have an NSMutableString called makeString. I want to create it at the beginning of my program without having to set its text. I then want to be able to set its text. I am currently using the following to create it. NSMutableString *make2String =…
Blane Townsend
  • 2,888
  • 5
  • 41
  • 55
2
votes
3 answers

Get String from NSMutableString in swift

What's the proper way of getting a String from a NSMutableString? I am currently using: var mutableString = NSMutableString(string: string) var string = mutableString.substring(from: 0) which seems a bit hackish... Thanks
Don Miguel
  • 882
  • 9
  • 19
2
votes
1 answer

Keep text and image together in AttributedString

I have an attributed string in Swift which displays an icon next to a username. This works great, my implementation looks like this: attributedUsername = NSMutableAttributedString(string: "username") let iconAttachment = NSTextAttachment() let…
PennyWise
  • 595
  • 2
  • 12
  • 37
2
votes
2 answers

NSCFString appendString leak while parsing xml

I am having trouble removing leaks from an iPhone app that i'm working on. I am parsing an xml feed to get data. Here is the code I am using to parse [[NSURLCache sharedURLCache] setMemoryCapacity:0]; [[NSURLCache sharedURLCache]…
Wizard Of iOS
  • 2,389
  • 2
  • 18
  • 22
2
votes
3 answers

Have trouble appending to an NSMutableString

@interface MainView : UIView { NSMutableString *mutableString; } @property (nonatomic, retain) NSMutableString *mutableString; @end @implementation MainView @synthesize mutableString; -(void) InitFunc { …
MGD
  • 723
  • 2
  • 11
  • 36
2
votes
0 answers

Unable to edit hosts or pf.conf file using objective c

I am trying to edit hosts file. But it gives error: sudo: no tty present and no askpass program specified. I have tried but its not working. Please help if anyone know. Thank You. NSMutableString* pfConf = [NSMutableString…