nsstring

NSString initWithBytes isNotEqualTo error

Hi all, i am using soap request in my application and using initWithBytes to convert the retrieved NSMutableData to NSString. NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; while i am running the app on the simulator everything works fine. but at the...

Problem with NSString and NSMutableURLRequest

I am having issues with adding a header to NSMutableURlRequest, the problem is that when I add the header below "Authorization" it does not show up. However if I replace my instance variable "auth" below with a static string exp (@"asdadsadsadga") it the "Authorization" header will show up. I am pretty lost at this point. NSURL *url = [...

Convert string to CLLocationCoordinate2D

Hi all, I have an array with NSString's in it. Some of these are latitude and longitudes and I need to use this with the below code. The latText and lonText are my strings that I am trying to use as co-ordinates.... CLLocationCoordinate2D pinlocation=mapView.userLocation.coordinate; pinlocation.latitude = latText; pinlocation...

Reusing a NSString variable - does it cause a memory leak?

Coming from a .NET background I'm use to reusing string variables for storage, so is the code below likely to cause a memory leak? The code is targeting the iphone/itouch so no automatic GC. -(NSString*) stringExample { NSString *result = @"example"; result = [result stringByAppendingString:@" test"]; // where does "example" go?...

Comparing Strings in Cocoa

I have tried: - (NSString*) generateString { NSString* stringToReturn = @"thisString"; return stringToReturn; } - (void) otherMethod { NSString *returnedString = [self generateString]; if (returnedString == @"thisString") { // Do this } else if (returnedString == @"thatString") { // Do that } } Which never...

NSString into bytes array

NSString *test=@"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; how to convsert this string to bytesarray... pls response me.. thanks and regards ...

Easy way to set a single character of an NSString to uppercase

I would like to change the first character of an NSString to uppercase. Unfortunately, - (NSString *)capitalizedString converts the first letter of every word to uppercase. Is there an easy way to convert just a single character to uppercase? I'm currently using: NSRange firstCharRange = NSMakeRange(0,1); NSString* firstCharacter = [da...

Making an NSMutableString transformation without leaking memory?

I have this function within an iPhone project Objective C class. While it's correct in terms of the desired functionality, after a few calls, it crashes into the debugger. So I think it's a case of bad memory management, but I'm not sure where. - (NSString *)stripHtml:(NSString *)originalText { // remove all html tags (<.*>) from the ...

Covert NSString to NSDate in a different timezone

Hi I am trying to convert a string to date in a separate time zone from the current system time zone. I have set the time zone of the dateformatter to this timezone. But the NSDate I get is always in my current time zone. For instance, my current time zone is PDT. I have set the DateFormatter's time zone to CST. I have a string with th...

Contents of UITextField and UITextView to NSString

I have a UITextView and 2 UITextField set up. UITextView resigns first responder status when empty part of the screen is tapped, the same for the 2 UITextField, plus for these 2, the return key also resigns first responder status. All 3 are declared in interface. I would like to get the contents of all of these to individual NSString an...

Encoding spaces in UITextView / UITextField to URL format

I'm trying to send the contents of UITextView or UITextField as parameters to a php file NSString *urlstr = [[NSString alloc] initWithFormat:@"http://server.com/file.php?name=%@&amp;tags=%@&amp;entry=%@",nameField.text, tagsField.text, dreamEntry.text]; When i log urlstr, the url format is ok just as long as the UITextView or UITextFi...

How do I convert NSString with Hexvalue to binary char* ?

I have a long hex value stored as a NSString, something like: c12761787e93534f6c443be73be31312cbe343816c062a278f3818cb8363c701 How do I convert it back into a binary value stored as a char* ...

Remove character from NSString in iPhone programming?

NSString *myString = @"A B C D E F G"; I want to remove the spaces, and get a string out like "ABCDEFG". Please help me... Thanks and regards ...

Creating object named after the value of an NSString - is it possible?

Is it possible to create an object named after an NSString's value? If so, how? ...

How do I draw an NSString at an angle?

Is there a set of string attributes I can specify that will draw the text at an angle when I call: [label drawAtPoint:textStart withAttributes:attributes]; ...

Truncate last part of an NSString

This should be a simple one, but my brains are a bit hazy today: I have an NSString * myOldString = @"This is a string (and this part is between brackets)" Now, I want to truncate the string in such a way, that basically everything between the brackets, including the brackets, is truncated. More precisely: I don't care what is happen...

NSDate and NSDateFormatter - short format date and time in iphone sdk

searched for answers, but the one's i found didn't seem to be ipone specific. I basically need to get current date and time separately, formatted as: 2009-04-26 11:06:54 edit: The code below, from another question on the same topic, generates now: |2009-06-01 23:18:23 +0100| dateString: |Jun 01, 2009 23:18| parsed: ...

NSString: Number of Occurrences of a Character?

I have an NSString and would like to get the number of occurrences of a particular character. I need to do this for quite a few characters, so it would be nice for it to be quick. In case it makes any difference, it's actually an NSMutableString, and the characters will all be uppercase English letters. ...

Does NSString stringWithCString: length: retain the byte array I pass in?

I'm working with AsyncSocket where the the AsyncSocket object calls a delegate method below whenever it receives data from remote end: - (void)onSocket:(AsyncSocket*)socket didReadData:(NSData*)data withTag:(long)tag; Now, within this method, I pass the NSData object into the following command to get a NSString representation of the ...

Strip HTML from web page on iPhone

Hello friends This is my code NSURL *url=[NSURL URLWithString:@"http://www.engadget.com"]; NSString *webPage=[[NSString alloc]initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; In the webPage string i got an html page of the link... In that string there is lot of tags and text... I want to ...