nsstring

NSString function

Hello I get a null return when i try out my NSString function. //Track.m static NSString* trackUrl; //static NSString* getTrackNumberUrl; @implementation Track - (NSString*)trackUrl { return @"http://site.com/?a="; } - (NSString*)setTrackNumberUrl:(NSString*)trackNumberUrl { if (trackUrl != trackNumberUrl) { return ...

NSString to ByteArray and back

I am implementing an interface, which specifies writeBytes() and readBytes() on a file. The data has to be transported as JSON. For readBytes I do the following: 1. NSFileHandle readDataofLength - to read from a file 2. NSString initWithData: encoding: - to specify a given encoding 3. NSString getBytes:buffer 4. put each buffer[i] into...

Cant set two NSStrings into one UITextView

Hi, I want to get NSString * test1 = @"one"; NSString * test2 = @"two"; to my UITextView. I wrote this: uitextview.text = (@"%@, %@",test1, test2 ); but the UITextView only gets the second NSString... Why? ...

Comparing strings in IF statements: unrecognised selector sent to instance...

in my code, I need to compare two strings to see if they are equal. if they are it needs to preform a function. one of the strings is just a @"someString", the other is part of an object. if ([[[mine metal] stringValue] isEqualToString:@"Gold"]) { //some function } however there are some complications when I do this. first, it gives ...

How to pull a string out from NSUserDefaults

Alright, I have my code, and I believe I have narrowed down the crashing bug to one section. Upon the view loading, my code loads the NSUserDefaults and pulls the string out of them. It then works with teh string. The problem is, I'm not sure how to pull the string out. Here is the relative code: NSUserDefaults *prefs = [NSUserDefau...

NSString Value of NSArray Object

I'm trying to figure out why this code doesn't work. I'm trying to search if a string contains "|P". If it does, I want to do something. NSMutableArray *list = [pView getPOIList]; NSString *cellValue = [list objectAtIndex:indexPath.row]; cell.textLabel.text = cellValue; NSArray *chunks = [cellValue componentsSeparatedByString: @"|P"];...

Help deciphering an NSString "passing argument ... from distinct Objective-C type warning"

Hi all, I am having trouble deciphering a "passing argument ... from distinct Objective-C type warning". I have a constant string declared as: extern NSString * const URL_1; and defined as: NSString * const URL_1 = @"http://someurl"; If I, say, assign that constant to an NSString as follows: NSString *URL = nil; ... URL = [[NSSt...

Cocoa: NSMutableString gives warning with stringValue

This works: NSString *myVar = @"whatever"; NSDecimalNumber *myNum = [NSDecimalNumber decimalNumberWithString:@"10"]; myVar = [myNum stringValue]; This version with mutable string produces warning "assignment from distinct Objective-C type": NSMutableString *myVar = [NSMutableString stringWithString:@"whatever"]; //UPDATE: CORRECT...

iPhone app hangs in [NSString drawInRect:withFont:lineBreakMode: alignment:]

I'm using the following function: CGSize s= [string drawInRect:CGRectMake(0, 0, w, h) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter]; string is a NSString and when this method is called - the iPhone is hangs for some time. I've set good values for the parameters. For a test, I wrote a loop with 99...

iPhone performSelector changes object type

I have a callback class with the method -(void)fire and it calls [target performSelector:selector withObject:dictionary]; Just before that line I added NSLog(@"%@", [[dictionary class] description]); to see where the object changed, when debugging it returns NSCFDictionary. So that was all fine. Next I went and added a similar line to g...

Search or compare within a Grapheme Cluster in Korean

In my current implementation of a UISearchBarController I'm using [NSString compare:] inside the filterContentForSearchText:scope: delegate method to return relevant objects based on their name property to the results UITableView as you start typing. So far this works great in English and Korean, but what I'd like to be able to do is se...

Alter NSString to get nothing back

Hi there. At two stages of my app's runtime, I am sending an NSString to the following method. I receive no warnings or errors in the code editor or the debugger, but when I NSLog the output (secondString), I only get given the memory address of the object. Is there something I am not doing right here? - (NSString*)validateString { ...

Stripping the 12 Hour clock suffix from an NSString

Hi I have a shortage of screen real estate for my time labels in my iPhone app. My solution is to have the time e.g. 12:00 on one line and then if the users current locale specifies that an AM-PM is used, have these in a second label below it. Since AM-PM also have localized variants I can't just look for the letters "AM" or "PM", then...

How to handle '&' in URL sent as HTML from iPhone Mail.app

Apologies if this has been answered already. There are similar topics but none that I could find pertaining to Cocoa & NSStrings... I'm constructing a clickable URL to embed in an HTML email to be sent via the MFMailComposeViewController on the iPhone. i create the url then use stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncod...

How to use NULL character with NSString

In php i can call base64_encode("\x00". $username. "\x00". $password) and the "\x00" represents a NULL character. I have a function that converts NSData to base64 encoded NSString created by DaveDribin. How do I create data from a string that has null characters? This doesnt seem to work... NSData * authCode = [[NSString stringWithFo...

Add backslash to String in Objective-c

I have a problem identical to this problem here. I even want to encode the same infromation as him (it's a date/time for asp.net)... When ever I try to add a backslash i get two backslashes since I used \. Everyone in the thread above has claimed that this is a problem with NSLog and that NSString does tread \\ as a \. I have checked ...

Regex of this <a href=\"-----------------\"> iPhone NSString

Hello Every one. I want to use regex for the following expression. here mail id can be any thing. but I just want to cut this string. I was trying following code. NSString *email=@"<a href=\"mailto:[email protected]\">"; NSString *strEmailMatchstring= @"\\b([a-zA-Z0-9%_.+\\-]+)@([a-zA-Z0-9.\\-]+?\\.[a-zA-Z]{2,6})\\b"; if(![...

Cannot strip newline from Cocoa NSMutableString ...

Hey, for the life of me, this is not working:.. NSMutableString *b64String = [[[NSMutableString alloc] initWithFormat:@"Basic %@", [string _base64Encoding:string]] autorelease]; [b64String stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; NSLog(@"(%@)", b64String); NSRange foundRange = [b64String r...

Remove double quotes from NSString

How do I remove double quotes from an NSString. Example: //theMutableString: "Hello World" [theMutableString replaceOccurrencesOfString:@"\"" withString:@"" options:NSCaseInsensitiveSearch range:(NSRange){0,[theMutableString length]}] It doesn't seem to work, maybe since I had to escape the " in the replaceOccurrencesOfString? ...

Adding an object with "text"

Hello, I'm stumped or just not finding info I need, I have an object that I want to save in an array when they select "saveDataround" button, however I can't seem to figure out how to populate the object with the text "Round": I'm getting an "Expected identifier" and "Expected , ;" errors on the first and second lines of code. Thanks in...