nsstring

Match NSString with image file names in loop

I have the following method: -(UIImage *)flagFromOrigin:(NSString *)originString { NSRange range; for (NSString *arrayString in countryArray) { range = [[originString lowercaseString] rangeOfString:arrayString]; if (range.location != NSNotFound) { return [UIImage imageNamed:[NSStri...

Memory / Obj-C proper object release. Which of these requires release?

Alright, this is an elementary question but I'm asking because I honestly don't understand how to properly manage this. If I uncomment the last two lines, this code crashes, even though I don't think it should. The following code is from a custom subclassed UILabel where I added the following method, setTextFromFloat. -(void)setTextFr...

Messed up method - if/then structure and string manipulation problems

I have a method that gets called any time a control on my view changes and should update a UILabel. It has two UITextFields and two UISliders. First I check to see if either of the UITextFields are empty and if so, advise that they need to be filled in. Otherwise I get the difference between the UITextFields' values and generate a cou...

obj-c NSString and alloc / retain / release

This is probably a question that is more about object alloc/retain/release, but I'll use NSString as an example. I'm aware that I can do: NSString* myString = [[NSString alloc] initWithString:@"Test"]; to essentially allocate and initialize a string referenced by my variable myString which I should later call [myString release] upon....

An Important Question about NSString

The problem is after i press 2 buttons the App crashes and I can't figure out why Button1 is wired to button1 Button2 is wired to button2 ... Button5 is wired to button5 What am I doing wrong? Basically I want to check if the sequence of #'s is punched in correctly (55235) In my AppDelegate.H file, I've defined a variable called NSS...

iphone: Large html document into string

I am building an HTML file which will later be emailed through my app. Currently I am creating the html by appending the strings together. This is a painful process. Is there another way that I can just put a large block of html into an NSString? Currently the line breaks in the string are screwing it up. ...

How to compare a string within a another string?

How to compare a string within a another string? Example: NSString *temp = @"english, french, japanese, chinese"; NSString *jap = @"japanese"; How do i compare the string "japanese" in temp with the string "japanese" in jap. Is there any function? Thanks in advance ...

How do I reliably pull a text file of unknown encoding into an NSString on an iPhone?

Here is some code which I use to pull a text file into a UITextView called textView. Because I can't always know the file's encoding ahead of time, I use the method -stringWithContentsOfFile:usedEncoding:error:, which stores an encoding value by reference. Once I have the encoding, I then open up the file and, if there's an error, prin...

iPhone: message sent to deallocated instance error

I have narrowed down this error (which crashes my app): -[NSConcreteMutableData release]: message sent to deallocated instance 0x6eaed40 to the following code: emailData = [kmlDoc dataUsingEncoding:NSUTF8StringEncoding]; But, I cannot figure out why this error is being caused? That line is just setting a very large string to an NS...

NSMutableArray of NSStrings contains actual data or just pointers to the data

I'm relatively new to Objective C and while I've been trucking right along writing iPhone apps, I think I need some help understanding something. I'm storing a dynamic list of strings in an NSMutableArray, which is a property of my main class. In my initialization I alloc and init to store 100 items: stringList = [[NSMutableArray alloc...

NSString Converting into a doubleValue after extracting NSString from UIPicker

I have : NSInteger dollarrow = [ValuesPicker selectedRowInComponent:kDollar]; NSString *dollar = [dollarlist objectAtIndex:dollarrow]; double converteddollar=0; I want to do a for loop on this and get the value in double , I am trying this : for(dollar=1;dollar<=99;dollar++) { converteddollar = converteddolla...

Problem using stringByReplacingOccurancesOfString in Objective-C

Hi, I'm having some problems working with NSStrings in Objective C... the code below returns a warning, saying: "'NSString' may not respond to '-stringByReplacingOccurancesOfString:withString:" NSString* NewWord = [Word stringByReplacingOccurancesOfString:@"!" withString:@""]; What ...

nsstring shows a different result when logged and when assigned

Hi , i have the following code : -(void)loadVersionDataToTable: (int)versionIndex{ OptimizationReportDate* datedVersions = [self.optimizationReport.datedResults objectAtIndex:0]; ReportDateVersion* version = [datedVersions.versions objectAtIndex:versionIndex]; ReportDateVersionSegment *seg = [version.versionSegments objectAtIndex:0]...

NSString: changing a filename but not the extension.

Times like this and my Objective-C noobness shows. :-/ So, the more I work on a routine to do this, the more complex it's becoming, and I'm wondering if there isn't just a simple method to change the name of a filename in a path. Basically, I want to change @"/some/path/abc.txt to @"/some/path/xyz.txt -- replacing the filename portion b...

Convert NSDate to NSString

I have the following: NSDateFormatter* df = [[NSDateFormatter alloc]init]; [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSDate* date = [df dateFromString:[sDate stringByReplacingOccurrencesOfString:@"Z" withString:@"-0000"]]; [df release]; I would like the output string to be "9/20/10" How can I do this? ...

iPhone convert NSString to NSURL error

I'm trying to convert the following NSString api call to a NSURL object: http://beta.com/api/token="69439028" Here are the objects I have setup. I have escaped the quotation marks with backslashes: NSString *theTry=@"http://beta.com/api/token=\"69439028\""; NSLog(@"theTry=%@",theTry); NSMutableURLRequest *url = [[NSURL alloc] URLWit...

How can I escape slashes and quotes in Objective-C?

I would like to do the following [controller setMessageBody:[NSString stringWithFormat:@"<strong>%@</strong> <br> <br> %@ <br><br> %@ <br><br> Sent From MyApp",self.articleTitle, self.articleDescription, self.articleURL] isHTML:YES]; on the last %@ I would like to do <a href="%@">Hello</a> But I am not sure how to escape it properly...

NSString is being returned as 'null'

Hi all, I have this simple method for returning the file path. I am passing the file name as argument. Then when I call this method this method returns 'null' if running on device but works fine on simulator. Is there anything I am doing wrong? -(NSString*) getFilePathForFile:(NSString*)fileName { NSArray *array = NSSearchPathForDi...

NSString returning jibberish

Totally lost with this one. Here's my code: theColor = [NSString stringWithFormat:@"white"]; NSLog(@"%s", theColor); Which is returing: †t†å I must be doing something stupid, but can not figure it out for the life of me. ...

NSString Question

Hi, I'm trying to extract the names from this list: new String: blood cz TheDeAtH TBH DragonFire Scotsman King Kot BobLeeSwagger AffeMitWaffe Jackobo D L fatality Jack bobo telex apa Tiger zip Guronzan no...