nsstring

Xcode String Format Error

Hi There, When debugging the following code NSString *var1 = @"blaa"; NSString *var2 = @"blaaaaa"; NSString* script = [NSString stringWithFormat:@"Set_Variable( %s, %s )",var1,var2]; the %s placehoders in script are replaced with funny gibberish characters. Can you see any errors in the code. Many thanks, (Confused .NET developer tr...

NSString into NSData

I wanna have a NSString object as NSData. Later this NSData-Object should return his stringValue with: NSData *data; NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; string shouldn't be nil... =D ...

NSString is integer?

How to check if the content of a NSString is an integer value? Is there any readily available way? There got to be some better way then doing something like this: - (BOOL)isInteger:(NSString *)toCheck { if([toCheck intValue] != 0) { return true; } else if([toCheck isEqualToString:@"0"]) { return true; } else { return ...

Convert NSDate to NSString

How do I convert an NSDate to an NSString so that only the year in @"yyyy" format is output to the string? ...

Objective-C NSString Question

I need to return a NSString from a function: NSString myfunc ( int x ) { // do something with x NSString* myString = [NSString string]; myString = @"MYDATA"; // NSLog(myString); return *myString; } So, I call this function and get *myString. Is that a pointer to the data? How can I get to the data "MYDATA...

Do NSString objects need to be alloc and init?

Noob question: I'm currently under the impression that when you want to create an object, you need to alloc and init that object. However, I've seen seen several sample codes where an NSString object is declared, yet I see no alloc or init messages following... A very simple example: NSString *myString = @"Hello World"; NSLog(@"%@"...

how to declare a two dimensional array of string type in objective c?

hey! i am new in objective c. i am trying to learn objective c. i would like to know how to declare two dimensional array of string type in objective c. ...

How to Convert NSInteger to a binary (string) value

I am trying to figure out how to convert an NSInteger, say 56, to an NSString that is a binary representation of the original (int) value. Perhaps someone knows a formatting technique that can accept 56 and return "111000" within Objective C. Thanks All. ...

iPhone: -[NSConcreteMutableData fastestEncoding]: unrecognized selector

Hello, I am trying to do this: self.somestring = [@"hardcodedstring" stringByAppendingString:someotherstring]; But I keep getting: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteMutableData fastestEncoding]: unrecognized selector sent to instance 0x1fb930' I don't call this meth...

How do I add a space between two concatenated NSStrings?

I have three string objects: NSString *firstName; NSString *lastName; NSString *fullName; The values for firstName and lastName are received from NSTextFields. I then want to concatenate the two strings and place the result in fullname. This is the code that I'm using: fullName = [firstName stringByAppendingString:lastName]; Howe...

Some times NSString become Invalid?

Hi, In my own iPhone Application I have used a number of nsstring variables to store values.But sometimes its value become Invalid!!!!Can anybody know what may be the reason? Or tell me about the situation when a nsstring variable becomes Invalid?? Thanks in advance, Syam ...

Question about character of NSString invalid in URL on iPhone

Some of my http request has 'space' in URL, but it is not recognized by iPhone. I have to change 'space' to '%20' whenever there is a 'space' in the url. Now I have to send a message typed by the user to the server and it can have as many 'spaces' as the user like. It looks like I have to replace them all.(stringByReplacingOccurrencesOfS...

Convert a Cocoa Touch latitude/longitude to a string without degree symbol

I'm trying to convert CLLocation latitude / longitude to a string. I can successfully do this with the follow code: // extract latitude from CLLocation object and cast to string NSString *latitude = [[NSString alloc] initWithFormat:@"%g°", location.coordinate.latitude]; this gives me a value like: 34.10111º. I would like this number...

BOOL to NSString

If I have a method that returns a BOOL, how do I cast that to a NSString so I can print it out with an NSLog? For example,I tried doing this, which isn't working: NSLog(@"Is Kind of NSString:", ([thing isKindOfClass:[NSString class]]) ? @"YES" : @"NO"); But I really want to actually turn the return value into a NSString... I know ...

iPhone SDK: Convert Byte Array to NSString?

XCode Newbie Alert! I am reading data from a TCP/IP stream and am successfully receiving a byte array from the pre-existing server. I am now trying to find a way to convert that array to an NSString. I have found several examples, but am having a hard time getting my desired results. case NSStreamEventHasBytesAvailable: { NSDat...

NSString contains a number, why does it crash my App?

I'm having some difficulty with NSString in my application. Basically, I have an NSString called o1string which contains the value "602". I want to output this in a UIAlertView alongside some other text. votedmessage = [ NSString stringWithFormat:@"The current standings are as follows:\n\n%@: %@ votes", b1title, o1string ]; UIAlertView ...

Storing a passwords in NSString without being readable in memory

I need to store passwords in NSString objects; however, I would like some way to obfuscate them, so they cannot be read directly from memory. This is a Mac OS X (10.5) application, but a solution that also works on iPhone would be much appreciated. ...

Best way to determine word wrap of a NSString in a UILabel

I have a line like: -Image- This is simply a test -Image- but I want to know how to separate the two lines. What to do here? The best way I could figure to implement on the iPhone is: UIImageView UILabel1 UILabel1 UILabel2 If there's an easier way to do this with the UI elements - i'm all ears. Otherwise, I'm...

Objective C strip out whitespace from NSString

How do I strip out the white space chars from an NSString ? Consider the following example: NSString *tmpString = @" Hello this is a long string! "; I want to convert that to: "Hello this is a long string!". I have tried a function like this, but it's not working: -(NSString *)cleanupString:(NSString *)theString {...

Maximum length of [NSXMLNode stringValue]

Hello all, I have an XML document which contains an element that is over 90,000 characters in length*. NSXMLNode* node = ...; NSString* val = [node stringValue]; // this is not the full contents of the node! The second line only gives me 80k or so. This is obviously not what I want, so I'd appreciate some suggestions. Is NSXMLNode b...