nsstring

When would initWithFormat:arguments: be used?

The NSString method initWithFormat:arguments: takes a va_list as an argument. I can't figure out when it would be used (or even how to use it). Why would Apple add such a method when the regular initWithFormat: is much more user-friendly? ...

Type casting for Core Data attribute setting

I am trying to set a Core Data attribute but am getting incompatible type errors. I have a float attribute in a Core Data entity on iPhone 3.0. Core Data auto-generates an interface for a managed data object that provides property access to it: @property (nonatomic, retain) NSNumber * volume; and an implementation for it: @dynamic vo...

Setting text for NSTextView with an NSString variable, considering reference counting

I have the following code in a function in my .m file: desc = [my executeFunction]; // desc is returned by executeFunction data = [desc objectAtIndex:0]; // data is declared in the .h file data2 = [desc objectAtIndex:1]; [myTextField setString:data]; // myTextField is connected to an NSTextView in IB [myTextField setString:da...

Objective C - Problem with objectForKey

Okay, I'm trying to write a high score function for my app. My problem is that when no high score has been saved yet, my program crashes. If I save it with: [[NSUserDefaults standardUserDefaults] setObject:@"[given string]" forKey:@"firstName"]; first, it works fine. However, if I start up the program for the first time and try to ...

Special Characters in NSString from HTML

Hello all, I'm fetching data from an XML source and parsing through it with tbxml. Everything is working fine until I get to a latin letter like the "é" it will display as: Code: é I don't see a proper method of NSString to do the conversion. Any ideas? ...

iPhone: Displaying Date in a Label and String Manipulation

In order to learn some basics I've undertaken creating an app that displays two quotes a day. I'm having trouble figuring out how to work with the current date, which will be pretty necessary if I'm going to get this thing running. My current plan is to name my .txt files with the quotes by day, and then get my filePath string to con...

Breakline in UIButton title

Hello people, in the following button is an address showed. My problem is the addresses are very long and how can i get between the two variables in the title of the button an breakline?? NSString *sitz = map.kordinate.herkunft; NSString *strasse = map.kordinate.strasse; NSString *strasseMitKomma = [strasse stringByAppendingString:@","]...

How to truncate an NSString based on the graphical width?

In UILabel there's functionality to truncate labels using different truncation techniques (UILineBreakMode). In NSString UIKit Additions there is a similar functionality for drawing strings. However, I found no way to access the actual truncated string. Is there any other way to get a truncated string based on the (graphical) width for ...

NSArray question - \n\t\t being added to the end of strings?

My strings are fine, but when they get added to an array a weird grouping of "\n\t\t" gets added to the end. So the string "Apple", becomes "Apple\n\t\t" when I look at the array description. Whats the deal with that? and how do I fix it? Addition: Its XML code. It seemed like [currentPlace appendString:string]; would get the right pa...

Convert NSString to Chunks of NSString that has a date format

This might be simple. I have searched, not found yet. How do I convert the NSString @"20100216190205" to an NSString of format @"yyyy-MM-dd HH:mm:ss". ie: @"2010-02-16 19:02:05" EDIT: I wanted to avoid using the NSDateFormatter to be more generic, for other situations. ...

How i break or make NSMutableSubstrings from NSMutableString in objective-C in iphone?

I m the beginner in iphone Thanks for sending me answer.... I want to break following NSMutable string into substring 200,8,"7 Infinite Loop, Cupertino, CA 95014, USA" I wanting only Cupertino and CA from above Mutable String. can it is possible in iphone in objective-C The above data is the mutable data, which is came from httpreque...

Format part of text in Custom Cell (iPhone-SDK)

Is it possible to format only a part of the text of a string? User searches, and if the search entry is found in the array, it will highlight that particular part of the text only. TIA. ...

iphone sdk , apostrophe showing up as question mark

The quotation marks (apostrophe to be more specific) single and double are displaying as question mark on my text view. The problem come up when I try to copy and paste some thing from a webpage and save it. This problem does not happen when I type the sentence. How can I replace a apostrophe with a regular single quote? ...

NSString retain copy question

Hi, I've seen a few posts on here about the issue of using retain or copy for strings. I still can't quite get my head around the difference or the importance. In my case at the moment I have a class with a whole load of nsstrings to hold strings. I want this class to only be instantiated once and I want its nsstring variables to chan...

Check NSString for special characters

Hi all, I want to check an NSString for special characters, i.e. anything expect a-z, A-Z and 0-9. I don't need to check how many special characters are present, or their positions, I just need to know whether a particular string contains any or not. If it does, then I want to be able to display "Error!", or something similar. e.g. jH...

Eliminate the char's in url strings

Hi i am new to iphone. i want to eliminate chars from %0A onwards in below url string and %20 also.please any one give some solns. case:1 http://www.sampleurl.com-feb 1.2161280%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20 case:2 %0A%20%20%20%20%20%20http://www.sampleurl.com-feb.html%0A%20%20%20%20%20%20%0A%20%20%20%20%0A%20%2...

how to adjust the horizontal gap between string with Drawing String Objects of NSString on iphone

Is there any api to adjust the horizontal gap between strings .I use the code - (void)drawRect:(CGRect)rect { hello =@"this is a test string string string string string string"; UIFont *hfont = [UIFont fontWithName:@"Arial" size:18]; [hello drawInRect:self.bounds withFont:hfont ]; } self is a uiview .it appear that ...

Override paste: to format text

Hello, I would like to capture a string being pasted into a control and apply some custom formatting to the string before being pasted. How is this possible? Thanks! ...

How do I convert NSMutableString to double for storing in Core Data?

Hi, my app needs to store latitude and longitude values parsed from XML into Core Data. Currently, I have a Core Data Model which has these attributes set to type double. The header file for the Model Object has them defined as NSNumber How can I convert the string stored in my CurrentNodeText variable into the required type for stor...

Is there a trick to see NSString values in an NSMutableArray in Xcode debugger?

When I debug, I never get the value of an NSString inside of an array. All I see are cryptic symbols, probably memory addresses of something like 0x1dc3753. I dig into all the stuff and expand everything, but no humanly readable value at all. Not really useful at all. How do you go about this (besides NSLogging everything)? ...