nsstring

Way to draw NSString on a curved path?

I have been looking for any example code for drawing a UILabel (or just an NSString or something) on a curved path, but have come up empty handed. Does anyone know whether it's possible to draw text on a curved path, like a circle or something, without using separate pieces of graphics for every single letter? ...

How to rasterize a string (mac)

I'm trying to take an NSString and rasterize it as a bitmap (an array of bytes (RGBA)) The closest I've gotten to any information on how to do something like this was in a forum post that suggested something along the lines of NSString *myString = [[NSString alloc] initWithString:@"This is a test"]; NSSize size = {256, 256}; ...

iPhone, show NSMutable Array containing NSStrings in UIPickerView

I have a method with the following code: NSMutableArray *pickerArray = [[NSMutableArray alloc] init]; int i; for(i = 1; i <= 7; i++) { NSString *myString = [NSString stringWithFormat:@"%@", i]; [pickerArray addObject:myString]; } for(i = 1; i <= 7; i++) { NSString *fieldName = [[NSString alloc] initWith...

Initialize custom class according to user selection

Hi, I have a navigation based application with two levels, in the second level the user select an option which should cause initialization and loading of the proper Nib file (there is a Nib file for every available selection). Now I'm doing the initialization in a switch, based on the user selection. The problem is that I'm adding Nibs...

Replace " " character in an NSString with "\ " (to create a Unix path)

Using the following doesn't work: - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement By doesn't work I mean does not do any replacement what so ever. It returns the same exact string. Is there a convenience method to do this? Similar to: - (NSString *)stringByReplacingPercentEsca...

SQLite Access in Objective-C and Cocoa

Hi Everyone, I am in the process of learning Objective-C for Mac/iPhone development and decided to try and write something useful without looking at the bible (Aaron Hillegass: Cocoa Programming 3rd Edition). I'm writing a simple puzzle game. The data that defines the levels is stored as a string in a SQLite database and read into a le...

NSString dataUsingEncoding not working?

I can't get this to work: NSString *string = @"!#€%&/()*^*_:;;:;_poawolwasnndaw"; NSData *stringData = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO]; stringData will be nil. Why? ...

How to declare a string in Objective-c?

How do I declare a simple string "test" to a variable? ...

iPhone Strange problem with NSString

Hi, I have following code which is called numerous times: NSString *Final = [ NSString stringWithFormat:@"%@%@%@%@.%@%@", str1, str2, str3, str4, str5, str6]; Every once a while Final string is set to nil, while str1 ... to str6 are perfectly valid string (I have verified in debugger)! I had this code originally, but every once a ...

Verify the existence of a word in an NSString

I searched a bit, but couldn't find an answer to this (probably very simple) question. I have an NSString, and I'd like to check if it contains a word. Something like this: NSString *sentence = @"The quick brown fox"; NSString *word = @"quack"; if ([sentence containsWord:word]) { NSLog(@"Yes it does contain that word"); } Thanks. ...

Advantage of data type id vs NSString in Objective C?

This code... NSString * s = [[NSString alloc] initWithString:@"Hello, World"]; s = s.lowercaseString; NSLog(@"%@", s); ...allows the use of dot notation but is strongly typed. This code... id s = [[NSString alloc] initWithString:@"Hello, World"]; s = [s lowercaseString]; NSLog(@"%@", s); ... is weakly typed and requires use of sq...

Casting in objective-c

I have a dictionary object that I am pulling data out of. The field is supposed to be a string field but sometime all that it contains is a number. I get the info using: NSString *post = [[temp objectAtIndex:i] valueForKey:@"POSTDESCRIPTION"]; So it is going into a string object. However, when I try to assign that to a cell's text via...

read double quotes and single quotes from Sqlite database.

Hi, In my application I am trying to read some data from sqlite database into UITextView. This text has double quotes as well as single quotes, for ex: she said : "Katie's purse has been lost" when I do this, I get strange characters in place of double and single quotes. Please help me with a solution to scrub these characters...

Formatting html tags in Objective-C

Hi, I am reading an data from an XML file for my iPhone application. This data contains html tags such as <p></p> <strong> <B>, etc in it. By using NSString class can i remove these tags and format the display of the text as needed. For example, if text inside the <p> </p> i want to display it in next paragraph. Is it possible? Pleas...

Parse Query String into a Structured NSDictionary

I have a query string: a=1&b=2&c[1]=3&c[2]=4 etc… I want a NSDictionary where a => 1, b => 2, c => [3,4]. Notice that that the value for c is an array. It should also be able to handle something like c[1][2]=5 to make an array of arrays c => [[5]]. Of course I can do it myself by splitting on the & and =, but what about other cases s...

What is the maximum length of NSString? Alternative to NSString - iPhone

-(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *theXML = [[NSString alloc] initWithBytes: [myWebData mutableBytes] length:[myWebData length] encoding:NSUTF8StringEncoding]; NSLog(@"%@",theXML); [self actualString:theXML extractMyData:@"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelop...

Replacing in NSString with wildcards / regular expressions - cocoa

NSString *x=@"\"/Sagar\' and \'Samir\' "; Now, I want to remove characters between these. \" / \' Intended output x = (should have) @"and \'Samir\'" So, Ms word give some options in find & replace, using wild card characters. ( just giving example ) Is it possible in cocoa? ...

Use NSString in a different file then one it's created in

How can I use an NSString in a file where that string wasn't created? ex. I created a string in thisone.m, but I want to use the same sting (ie the same data) in thatone.m the data from this string will be coming from a UITextField ...

Obj-C: Difference between "Fairfield" and @"Fairfield" (with at string)?

I just had a ridonkulous typo in my iPhone app, answered here. Now I'm wondering about the @"..." notation. why this works: NSArray *someArray = [NSArray arrayWithObjects: @"Fairfield", nil]; and this does not (even though it compiles, it will throw an EXC_BAD_ACCESS): NSArray *someArray = [NSArray arrayWithObjects: "@Fairfield", n...

Strip Non-Alphanumeric Characters from an NSString

I'm looking for a quick and easy way to strip non-alphanumeric characters from an NSString. Probably something using an NSCharacterSet, but I'm tired and nothing seems to return a string containing only the alphanumeric characters in a string. ...