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

Categories for NSMutableString and NSString causing binding confusion?

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…
farhadf
  • 1,918
  • 3
  • 19
  • 27
2
votes
2 answers

Why is my NSSMutableString potentially insecure?

Why is my NSMutableString potentially insecure? I searched for this but couldn't find anything. int hour = [number intValue] / 3600; NSMutableString *time = [[NSMutableString alloc] initWithString:@""]; if (hour < 9) { [time…
Tomasz Szulc
  • 4,217
  • 4
  • 43
  • 79
2
votes
1 answer

Can't save file to disk, no clue why

I'm trying to write a string to disk: return [fileContent writeToFile:path atomically:YES encoding:NSUnicodeStringEncoding error:error]; But it always fails with the following error: Error Domain=NSCocoaErrorDomain Code=4 "The folder “ddd.csv”…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
2
votes
2 answers

Better way to handle arrays in Objective-C?

Please let me preface this question with an apology. I am very new to Objective C. Unfortunately, I have a very tight timeline on a project for work and need to get up to speed as fast as possible. The code below works. I am just wondering if…
Sagan
  • 45
  • 3
1
vote
2 answers

Converting numeric values in OBJC to values of time? (hours instead of percent of an hour)

I'm currently trying to convert xml values that represents two times. example: 960 975 i store these 2 values into two doubles: double From = from; double To = to; Now, if i do From=From/60; To=To/60; and NSString…
Jens Bergvall
  • 1,617
  • 2
  • 24
  • 54
1
vote
2 answers

Replace "\r\n" in NSMutableString, Data received from Server

Im getting data from a server by executing this code: - (void) sendGeneral:(NSString *) general{ self.responseData = [NSMutableData data]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:CBURL]]; …
Shimon Wiener
  • 1,142
  • 4
  • 18
  • 39
1
vote
1 answer

NSScrollView scrolling issue

I'm trying to add link attributes to the NSMutableString of a NSTextView. Since I only want to add the link to the visible text with the text view, I observe the NSScrollView for scrolling changes with the NSViewBoundsDidChangeNotification…
brutella
  • 1,597
  • 13
  • 26
1
vote
1 answer

Clearing NSTextfield bound to a nsmutablestring

I have a text field bound to a nsmutableablestring. In the action item for a button I want to clear this string but it's throwing an exception saying it's immutable. Member variable is NSMutableString* firstName; Property for binding to the…
JonF
  • 2,336
  • 6
  • 38
  • 57
1
vote
2 answers

Converting a NSMutableString to a float value

In my app I am getting values from a bunch of sliders and converting them to a NSMutableString in the AppDelegate. However, I need to recall these values later on so I can do some calculations with them, but I can't reconvert these values back to a…
1
vote
2 answers

Objective-C - Replace all double new lines with 1 new line?

I have an html string, and I want to allow 1 linebreak at a time. I am trying to replacing all "\n\n" with "\n". But at the end I end up with double line-breaks. Is it possible to print the content of a string to see what the content is, so instead…
aryaxt
  • 76,198
  • 92
  • 293
  • 442
1
vote
2 answers

NSString problems

I have problems with a simple NSString on Mac OS X: NSString *letters = @"abcdefghijklmnopqrstuvwxyz0123456789"; myString = [myString stringByAppendingFormat:@"%c", [letters characterAtIndex:3]]; When I try to access this string again, Xcode is…
Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
1
vote
2 answers

NSMutableString memory leak

I am getting memory leak in instruments in the code -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableString * res = [[[NSMutableString alloc]…
Rams
  • 1,721
  • 12
  • 22
1
vote
1 answer

NSMutableString: Need to insert no value instead of (null)

I am passing the value of string to a web service. if the string has some value then it is ok. but if does not contain any value which is null, it prints (null). for eg: NSMutableString *str1 = [NSMutableString stringWithFormat:@""]; NSString…
Hanuman
  • 642
  • 5
  • 19
1
vote
1 answer

Objective-C NSMutableString Copying

I did a poor job of explaining my original question, so here's a second stab. From a top down perspective, here's the goal: I have a map class that is using DDXML to parse and load in an XML map file. This map file has several strings for a…
David
  • 597
  • 5
  • 17
1
vote
3 answers

Usage of NSString and NSMutableString objects in Objective C

I need to use a bunch of string variables throughout my program. I reassign some of them quite often, while others are stuck with the same value during execution. What's the best practice here? In the first case, the variables should be…
Ricky Robinson
  • 21,798
  • 42
  • 129
  • 185