nsstring

[iPhone app] Inserting special char un NSString for URL use

Hi, I'm using HTTP connection to share data with my JSON server. I use URLs like "MyServlet?param1=value1" and so on... I'm now facing a problem with one of my servlet (I can't change it because some other views are using it) : The servlet is working with a syntax including those symbols "{" and "}". The exact syntax is {(value1_va...

Getting the substring from a certain character in NSString

If I have an NSString that is initially: "ABCDE*FGHI" How do I make it turn into "FGHI" In other words, everything from the asterisk onwards is kept. Likewise, how would I turn it into: "ABCDE" (everything up to the asterisk is kept) Thanks ...

What is the difference between these two ways of creating NSStrings?

NSString *myString = @"Hello"; NSString *myString = [NSString stringWithString:@"Hello"]; I understand that using method (1) creates a pointer to a string literal that is defined as static memory (and cannot be deallocated) and that using (2) creates an NSString object that will be autoreleased. Is using method (1) bad? What are t...

NSString simple pattern matching

Hi all, Mac OS 10.6, Cocoa project, 10.4 compatibility required. (Please note: my knowledge of regex is quite slight) I need to parse NSStrings, for matching cases where the string contains an embedded tag, where the tag format is: [xxxx] Where xxxx are random characters. e.g. "The quick brown [foxy] fox likes sox". In the ab...

Problems with converting a CGPoint to a string.

I have been having problems with converting a CGPoint to a string. I have tried various methods, but this seems like the most promising but it still won't work. Any suggestions? Here is my code: -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; coord = [touch lo...

What is the guaranteed lifecycle of -[NSString UTF8String]?

The docs vaguely say that it will stick around as long as needed, but when is it actually deallocated? When the original NSString is deallocated? When the current autorelease pool clears? Sometime else? Furthermore, when is it guaranteed to stay for, as opposed to the current implementation? If it stays for the lifetime of the NSStr...

iPhone .. NSString being released & dealloc -- but I cannot tell where or why...

This is KILLING me! I have a view. in the .h file i do this: @interface SearchLogs : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, UIActionSheetDelegate, UIPickerViewDelegate> { NSString *startDate; NSDateFormatter *thisFormatter; } @property (nonatomic, retain) NSString *startDate; @property (n...

confused about NSString *str ...

I am kind of confused by the behavior of NSString *str.. I assigned it in several ways, sometimes it works, and sometimes it becomes null. NSString *str = @"/hi/hello"; // this one always works // this sometimes becomes null after the function ends NSString *str2 = [str lastPathComponent]; // as above NSString *str3 = [NSString string...

Check if a C enum exists

How would I check that NSRegularExpressionSearch exists before using it? enum { NSCaseInsensitiveSearch = 1, NSLiteralSearch = 2, NSBackwardsSearch = 4, NSAnchoredSearch = 8, NSNumericSearch = 64, NSDiacriticInsensitiveSearch = 128, NSWidthInsensitiveSearch = 256, NSForcedOrderingSearch = 512, NSRegularExpressionSearch...

Objective c select statement

hey guys im trying to do a SELECT Statement from a local SQLDB so my statement is something like select ..etc..etc WHERE Date =%@,theDate theDate is an NSString variable. i NSLoged theDate and it returned 22/06/2010 But it doesnt work so i tried the following select ..etc..etc WHERE DATE ='22/06/2010' And the values came by. any idea ...

How can i share a NSString between classes

Is there anyway that i can define an NSString. Inside of one class then access its value inside of another class? ...

NSArray objectAtIndex is not working. Please help

NSArray* address = [NSArray arrayWithArray:[detailItem addressArray]]; NSLog(@"address = %@", address); NSString* addressToString = @""; int arrayCount = [address count]; for (int i = 0; i < arrayCount; i++) { addressToString = [addressToString stringByAppendingString:[address objectAtIndex:i]]; if (i == arrayCount -1) { ...

Why NSString says it is "Invalid", objC, IPhone?

I have a ViewController, i declare NSString *xTitle at the top in testViewController.m file when i set the xTitle=@"anytext" in viewload event; and i tap a button, it shows the UIActionsheet. i try to read xTitle in UIActionSheet's clickedButtonAtIndex. i see the xTitle's value "anytext", its ok. but when i set the xTitle from NSDic...

encoding string for URL problem!

I have to POST data to a php page from an Iphone application, so i need to encode the parameters properly, converting the special characters... Specifically i need to send the UDID of the iphone. I've found many helps on the web to encode the String to pass as parameter, but i got a strange error. I'm using this function: - (NSString...

Objective C ==> unichar[] to NSString ????

I have an array of unichars i need to convert it to nsstring. How can i do this? ...

Using NSString stringWithFormat: with a string from NSDictionary

I'm getting an NSString from a dictionary that needs to have a variable integer, something like: "You have %i objects." How do I put the calculated integer value into the string? I would like to do something like NSString *string = [NSString stringWithFormat:[dictionary objectForKey:@"string"] But I don't know how to pass in an arg...

NSMutableString defining and redefining

I am at a loss as hot to properly initiate a NSMutableString, I have tried: NSMutableString *string = @"some text"; which is the same method one assigns a string to an NSString but have hade no luck. Additionally I have not been able to figure out how to redefine the string contained with the NSMutableString. I would imagine it would ...

NSScrollview may not respond to '-text'

I am having trouble assigning a NSString to the text of a NSScrollView. I have tried the following: NSString *medium = codeView.text; That didn't work so then I tried: NSString *medium = [codeView text]; This still doesn't work and it gives me the warning: NSScrollview may not respond to '-text' Or in the case of ...

Extract pattern substring from NSString

Hi, I've created my own UITabBarController. Additionally I've written a few lines of code to determine the current user. E.g. if I am the current user do/display this, otherwise do/display this etc... The format pattern is (firstname Lastname). The Full name of the current user is in "displayName". This is how I set the title of th...

Loading an Array Image item using the formatted NSString

I want to load an image from an array and set the view to display this image. The current code isnt loading anything, just a gray image full screen. myView.image = [UIImage imageNamed:[names objectAtIndex:r]] If I have a counter r, which I use to access the index. How could it be done to load an image as such myView.image = [UIImage...