nsstring

How can I underline part of the text like iPhone SMS?

I use an UILabel to show my text, in a multi-line and UILineBreakModeWordWrap mode, and the maximum width is 200. For example, here is the text: I really really want to underline first word and second word, could you help me? And I want to underline "first word" and "second word". If the text is shown in a single-line mode, with siz...

Objective C NSString problem

I have a NSString that I need to examine character by character and: examine char perform calculation loop (until string ends) Any thoughts on the best way to do this? Do I need to convert the NSString to a NSArray or C string? ...

NSString stringWithContentsOfFile failing with what seems to be the wrong error code

Hello. I'm trying to load a file into a string. Here is the code I'm using: NSError *error = nil; NSString *fullPath = [[NSBundle mainBundle] pathForResource:filename ofType:@"html"]; NSString *text = [NSString stringWithContentsOfFile:fullPath encoding:NSUTF8StringEncoding error:&error]; When passed in @"about" as the filename, it w...

Objective-C and ASIHTTPRequest - response string problems

Hi guys, I'm using the ASIHTTPRequest package to send some data from the iPhone to my server and then when saved on server I recieve a response (a string) containing a url that I want to load in a webview. In theory this should be simple, but in reality I can't get this work at all. Seems to be some problems with encoding of the string I...

NSStream, UTF8String & NSString... Messy Conversion

I am constructing a data packet to be sent over NSStream to a server. I am trying to seperate two pieces of data with the a '§' (ascii code 167). This is the way the server is built, so I need to try to stay within those bounds... unichar asciiChar = 167; //yields @"§" [self setSepString:[NSString stringWithCharacters:&asciiChar length...

Remove newline character from first line of NSString

How can I remove the first \n character from an NSString? Edit: Just to clarify, what I would like to do is: If the first line of the string contains a \n character, delete it else do nothing. ie: If the string is like this: @"\nhello, this is the first line\nthis is the second line" and opposed to a string that does not contain a ...

Separate NSArray to a list of NSString type objects

A UIActionSheet is initalized with: UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Button1", @"Button2", nil]; I am trying to pass an NSArray into the "otherButtonTitles" message. I tried to pass an NSArray using: ...

How to create an NSString with one random letter?

Hi, I need to create an NSString that has a single random uppercase letter. I can get random int's fine, and I could construct a C string from it and then make the NSString, but I imagine there has to be a better and more cocoa-ish way. Thanks! ...

Inserting an NSString into NSBundle's pathForResource?

This animates the UIImageView in the impactdrawarray: if ( ((impact *) [impactarray objectAtIndex:iv]).animframe == 70){ ((UIImageView *) [impactdrawarray objectAtIndex:iv]).image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"explosionA71" ...

stringWithContentsOfURL not working with certain string

Hello, I have code similar to the following with a URL like this... If I use the first *url, webpage will return null. If I put this URL into a URL shortening system like bit.ly it does work and returns the pages HTML as a string. I can only think I have invalid characters in my first *url? Any ideas? NSString *url =@"http://www.t...

Objective-C: Reading a file line by line

What is the appropriate way of dealing with large text files in Objective-C? Let's say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of doing this? One solution is using the NSString method: + (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding...

iPhone NSString convert to readable text

I have a piece of NSString that will read "Test & Test" or with " Is there any way without searching and replacing to make that display as "&" or """ ?? ...

How to create a NSString from a format string like @"xxx=%@, yyy=%@" and a NSArray of objects?

Is there any way to create a new NSString from a format string like @"xxx=%@, yyy=%@" and a NSArray of objects? In the NSSTring class there are many methods like: - (id)initWithFormat:(NSString *)format arguments:(va_list)argList - (id)initWithFormat:(NSString *)format locale:(id)locale arguments:(va_list)argList + (id)stringWithForma...

Split String at specific line for NSString

Hello ist there a way to split a String for UITableView at a specific line to put the "rest" (the second part of the data) in an own cell NSString *data; CGsize *size = [data sizeOfStringWithFont:[UIFont systemFontOfSize:14] constrainToWidth:280.0]; if the size.height e.g. is greater than 1500 i want to split the string at this li...

Objective-C Problems with NSDictionary and NSURL

Hi, I am new to Objective-C and I have no clue why this code is not working: NSMutableDictionary *bookmarks = [NSMutableDictionary dictionaryWithCapacity:(NSUInteger) 4]; [bookmarks setObject:@"Stanford University" forKey:[NSURL URLWithString:(NSString *) @"http://www.stanford.edu"]]; [bookmarks setObject:@"Apple" forKey:[NSURL URLW...

Unfamiliar C syntax in Objective-C context

I am coming to Objective-C from C# without any intermediate knowledge of C. (Yes, yes, I will need to learn C at some point and I fully intend to.) In Apple's Certificate, Key, and Trust Services Programming Guide, there is the following code: static const UInt8 publicKeyIdentifier[] = "com.apple.sample.publickey\0"; static const UInt8 ...

how to remove first 3 characters from nsstring?

i have a string like this A. rahul VyAs and i want to remove A. and the Space After The A. so that new string would be rahul VyAs how do i achieve this? ...

NSString newbie question about setting a char from it.

Ok, I know this is a very basic question, but my head is swimming in NSString vs C string nonsense. Basically I have a NSString the just contain 1 character for example the letter D How do I take that 1 character NSString and assign it to a variable of char So I have... char mychar; NSString *myMode = [[NSString alloc] initWithFo...

Objective C if and appending NSMutableString statements/modification

I have a complex question which may be very simple for you guyz. I have a NSMutableString = "This is spinach"; I have 3 Booleans. Please ignore the code. I havent used proper syntax,functions. if (boolA) appendstring"and apples"; if (boolB) appendstring"and mangoes"; if (boolC) appendstring"and oranges"; every boolean cor...

how to add ' in the nsstring in iphone?

i have a string like this nsstring *mystring=@"RahulVyas"; now i want to add this ' so the new string would be 'RahulVyas' any way to do this? ...