nsstring

Objective C 's NSString subStringToIndex causing strange issue.

Hi everyone I am working on a game and I have run into a really weird issue and was hoping to get some help. Basically sometimes the text is a bit long to show in one textbox so I wanted it to break down a string and store the undisplayed text in a string to be used in the next message box. So when I use this code.. NSString * Talkin1 =...

printing int with specified nr of digits

I am trying to print out a 5 digit number as follows: int rdmNr = arc4random()%100000; NSLog(@"%i",rdmNr); I always would like to have 5 digit numbers. Example outputs should be: 00001 10544 00555 78801 But with the previous code I would also get 1 or 555 without 0s. I also tried %5i, but the I just get more white spaces. ...

Best way to strike out a text

Hi there Was is the best solution so far for a strike out text on the iPhone I heard of multiple solutions: Something wth three20 Image as a subview UIWebView and something with a NSAttributedString, but I don't find a working example for that. Cheers ...

Objective C, unescape unicode characters

Does anyone have better solution or ideas than http://stackoverflow.com/questions/2099349/using-objective-c-cocoa-to-unescape-unicode-characters-ie-u1234 for unescaping unicode characters in NSString? ...

How do I include a quote character in a string?

i have to make a web request but It' format creating problem for me it is like i require www.abc.com?userID="YourUserID" here the problem is i am creating following NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.abc.com?userID=%@",myID]]; which will create a url with string www.abc.com?userID=12345 but...

Data from webservice returns me nil value in iPhone

I am using following lines of code to convert the data (NSData) to NSString. I am getting nil value from string. But I get around 640 bytes from the server. The problem occurs only when we convert data to NSString. I used NSASCIIStringEncoding, NSUTF8StringEncoding, NSUnicodeStringEncoding for encoding parameter. Can someone shed light o...

How can I parse a longer JSON file than a NSString ?

Hi ! I'm a bit stuck in a project. I was writing some code to get a JSON file and store it in an NSString before parsing it into a NSArray. But I get an error: 2010-10-27 20:59:44.813 GeraldKervyn[21752:207] -JSONValue failed. Error trace is: ( "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading chara...

NSURL fileURLWithPath where NSString has a space

Hello, I've looked at quite a few of the related questions and cannot find a similar problem or a solution so my apologies if there is a duplicate out there somewhere. Anyway, I'm trying to generate a file's NSURL to use with an NSXMLDocument. I have the following components: const NSString * PROJECT_DIR = @"~/SP\\ BB/"; const NSStrin...

Objective-C arrayWithPlist (that's already in an NSString)

I have an NSString that already contains a pList. How do I turn it into an NSArray? (WITHOUT saving it to disk, only to reload it back with arrayWithContentsOfFile, and then have to delete it.) Where is the make arrayWithPlist or arrayWithString method? (Or how would I make my own?) NSArray *anArray = [NSArray arrayWithPlist:myPlistS...

How can I convert the characters in an NSString object to UILabel objects?

Hello. I'm trying to figure out how to take the individual characters in an NSString object and create UILabels from them, with the UILabel text set to the individual character. I'm new to Cocoa, but so far I have this... NSString *myString = @"This is a string object"; for(int i = 0; i < [myString length]; i++) { //Store the cha...

Problem with NSStrings and UIAlertView

I have having a very odd issue when utilizing this UIAlertView. When viewing a Physician they have several offices. Upon selecting one you get an alert that offers to call this location or display it on a map. To create the alert and to have data at the ready when the alert is dismissed, I declared 4 NSStrings (although I probably only n...

Issue posting variable with iPhone SDK

Hey everyone, I am encountering an issue while posting a variable with Xcode: While running this code the app crashes while posting the variable to a webservice: NSArray *array = [stringFromFile componentsSeparatedByString: @","]; NSString *time = [array objectAtIndex:1]; UTCorLocal = time; NSLog(@"%@", UTCorLocal); UTCorLocal varia...