nsstring

Check NSString Contains Both Letters And Numbers

Hi I'm looking for the best way to check that an NSString contains both numerical and alphabetical characters. What I have come up with so far is the code below but his just tells me that now characters were entered which aren't number or letters. if( [[myNSString stringByTrimmingCharactersInSet: [NSCharacterSet alphanum...

Objective-C how to print out leading 0 for a float?

How do you print out leading zeros for a float using NSString type? Input: 3.14 Desired Output: 03.1 Using Format: @"%02.1f" Output is 3.1 ...

NSString length limit

How can I limit the length of a NSString? I would like to keep it below to equal to 100 characters/ ...

NSString and UTF8 Hex Conversion

In this function, I get the selected emoticon from NSTableView from the NSArrayController connected to an IBOutlet called emotes. The string in the selected NSArray contains UTF8 characters that is sent to the clipboard. // Get Selected Emoticon NSArray * selectedemote = [emotes selectedObjects]; NSLog(@"%@",[selectedemote valueForKey:@...

How to convert std::string to NSString?

Hi I am trying to convert a standard std::string into a NSString but i'm not having much luck I can convert successfully from an NSString to a std::string with the following code NSString *realm = "Hollywood"; std::string REALM = [realm cStringUsingEncoding:[NSString defaultCStringEncoding]]; However i get a compile time error when i...

How to encode hebrew string (NSString) into a Unicode format in order to send as a URL in Objective-C

The title pretty much sums it up. I have a hebrew-containing String used in a NSUrl: NSString * urlS = @"http://irrelevanttoyourinterests/some.aspx?foo=bar&this=that&Text=תל אביב" I would like to convert in into: Text=%u05EA%u05DC%20%u05D0%u05d1%u05d9%u05d1 and then send it as a GET request. I have tried many encoding metho...

Autorelease NSString

Am I responsible for releasing this string, and is it autorelease by default? // command is of type NSData* char cAddress[12]; [command getBytes:cAddress range:NSMakeRange(5,12)]; NSString *someString = [NSString stringWithCharacters:(const unichar*)cAddress length:12]; ...

how to convert NSString to NSMutableArray?

hi, i have an NSString that is value in plist format. i download this string from url. but i dont wanna write it to a file. when the string comes Asynchronous, i want to put it to nsmutablearray. how can i convert string (in plist format) to nsmutablearray? there is some methods, initWithContentsOfURL, initWithContentsOfFile. but no inti...

How to use a placeholder with an NSString

I am currently using this code to put some text on the screen userOutput.text=@""; I want to be able to display an int variable in the string, like you do with printf in C with the %d placeholders. How do I do this with an NSString ...

How to delete the char in the NSString?

Hi, everyone, I have a question about the objective-C. I have the following string NSString *data = @"abcdefghi"; but I want the data to be the "defghi" What can I do? Can anyone help me? Thank you. ...

Cannot addObject into a NSMutableArray?

Hi, everyone, I have a question about the objective-C. I use the following code to add a contains from an array to another array. However, the second array is null. Can anyone help me? Thank you. titleArray = [[csvDataArrayString objectAtIndex:0] componentsSeparatedByString:@","]; NSString *title; dataTitleArray = [[NSMutableArray al...

Convert quoted strings in a CSV to an NSMutableArray without the quotes.

Hi, everyone, I have a question about the objective C. I have the following NSString *name shown below: "First Name","Second Name","Last Name"; Actually, name is the header of the CSV and receive from the URL. And I use the follow statement to break the statement to array. NSMutableArray *csvTitleArray; csvTitleArray = [[name compo...

How to declare variables in a class that do not release?

I need to create two instances of two classes inside a view controller that stay alive for the entire time that view is open. Inside theese one of theese classes I need to create a NSString and a NSDate that stays alive for the entire time the class is alive. How do I do this? ...

Sort Date[dd/MM/yyyy] which is in NSString data type inside an array in Objective-C for iPhone

Hello, I have an NSMutableArray which holds the dates in format dd/MM/yyyy of type NSString. Now i need to display the sorted array of dates. Please suggest me how to achieve it. Thank You. ...

How can I make sure nothing gets autoreleased?

I need a way to create variables that are accessible for the entire time my custom class is initiated to when I call the release function. I need to retain a NSDate and a NSString. ...

Objective-c iphone App, problems with button to parsed hyperlink

Hi! Another problem for me with my application is a simple procedure. I want to have a button which, if you press, opens the link associated with the article in question. I have followed instructions that i understand, but I am having trouble understanding why the link will not work. - (IBAction)link:(id)sender { WebViewController *vi...

Using an NSString and UIImageView to load image from URL, failing on some URLs

I've got some code to load an image from a URL, it seems to work ok. Unless the URL contains curly brackets. This seems like it is a string formatting problem? I can't figure it out. ex @"http://site/image.png //works @"http://site/{image}.png //doesn't work NSString* mapURL = @"http://site.com/directory/{map}.png"; NSLo...

NSString isEqualToString: does not work. Why?

Hello, I create an NSString using, NSString *myString = [[NSString alloc] initWithBytes:someBuffer length:sizeof(someBuffer) encoding:NSASCIIStringEncoding]; I used NSLog to output myString and it displays "Hello". If this is the case, then why does this fail. NSString *helloString = @"Hello" BOOL check = [myString isEqualToStri...

Extract RSS Feed URL from NSString - iPad

Hey, I'm loading a website's html code using NSString - NSString*webViewText = [NSString stringWithContentsOfURL:[NSURL URLWithString:[self getCurrentURLFromWebview:browser]] encoding:1 error:nil]; and I'd like to extract the RSS feed from them, but I got a few questions. From what I know, most feeds are included in the website as such...

Release of NSString Causing EXC_BAD_ACCESS

Thanks for your help on this one. I am pulling a NSDictionary from a plist in my main bundle and am having troubles. Here is the code: - (void)viewDidLoad { // Pull in FAQ from Plist NSString *strFAQPlist = [[NSBundle mainBundle] pathForResource:@"FAQs" ofType:@"plist"]; dictFAQList = [[NSDictionary alloc] initWithContents...