nsstring

Having a problem with reading a file using NSString initWithContents OfFile

In this program when I debug, it is showing the nil for fileNameString. I could not understand what is the problem. Please help me ? @implementation fromFileRead1 NSString *fileNameString; -(id)init { if( (self = [super init]) ) { fileNameString = [[NSString alloc] initWithContentsOfFile: @"enemyDetails.rtf" encoding:N...

strchr in objective C?

I'm trying to write the equivalent of strchr, but with NSStrings... I've currently got this: Boolean nsstrchr(NSString* s, char c) { NSString *tmps = [NSString stringWithFormat: @"%c", c]; NSCharacterSet *cSet = [NSCharacterSet characterSetWithCharactersInString: tmps]; NSRange rg = [s rangeOfCharacterFromSet: cSet]; ret...

NSString drawAtPoint Crash on the iPhone (NSString drawAtPoint)

Hey. I have a very simple text output to buffer system which will crash randomly. It will be fine for DAYS, then sometimes it'll crash a few times in a few minutes. The callstack is almost exactly the same for other guys who use higher level controls: http://discussions.apple.com/thread.jspa?messageID=7949746 http://stackoverflow.com/...

Check if last characters of an NSString are numbers.

Is it possible to see of a string ends with a number which length is not known? "String 1" -> 1 "String 4356" -> 4356 "String" -> nil If so, how can I determine that number? ...

Global variable call working only first time

Hello, I defined a global variable that is called from other view and it is working first time but not following ones, it keeps with value from first call! Suppose that is a cocoa fundamental problem and variable is not properly defined according its need. Thanks for any idea to solve it. declaration: @interface TableArchiveAppDelegate...

I don't know How to release NSString.

NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [path objectAtIndex:0]; NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"DB"]; NSString *fileName = [newWordbo...

objective C NSString retain

If I create a String with [NSString StringWithFormat], do I have to [retain] it? My understanding is that convenience methods add the objects to autorelease pool. If that is the case, shouldn't we retain the object so that it doesn't get drained with pool at the end of the event loop? ...

Determining credit/debit card type

Hi, I'm writing a POS application for the iPhone/iPod combination, using the same exact hardware used in Apple Stores:: EasyPay. Ok, my hurdle is this: how do I identify which credit card type is being used as text is entered in the uitextfield? I assume I've to use textField:shouldChangeCharactersInRange:replacementString:? However, I...

NSString's stringByAppendingPathComponent: removes a '/' in http://

I've been modifying some code to work between Mac OS X and iPhone OS. I came across some code that was using NSURL's URLByAppendingPathComponent: (added in 10.6), which as some may know, isn't available in the iPhone SDK. My solution to make this code work between OS's is to use NSString *urlString = [myURL absoluteString]; urlString ...

iPhone OS: Using an NSString variable to specify a property or ivar

I have a program that I want to either hide or show certain UIbuttons depending on certain variables and all the buttons are named incrementally like 'button1, button2, button3.' So I want to iterate through the buttons but I don't know how to address the button in an assignment statement using an nsstring as a variable inside a dot not...

Can I separate an NSString by more than 1 separator?

I would like to separate my string by spaces, commas, periods (ie. punctuations). I am using: [myString componentsSeparatedByString:@" "]; to separate by spaces, but need to be able to split by punctuations as well. ...

How to replace a character in NSString without inserting a space?

Let's assume I have the string NSString* myString = @"Hello,"; How can I remove the comma without leaving a space? I have tried: NSString* newString = [myString stringByReplacingOccurrencesOfString:@"," withString:@""]; and NSString* newString = [myString stringByTrimmingCharactersInSet:[NSCharacterSet punctuationCharacterSet]]; ...

Validate NSString

I am validating an NSString to ensure that the string does not contain apostrophes. The code I'm using to do this is NSCharacterSet * invalidNumberSet = [NSCharacterSet characterSetWithCharactersInString:@"'"]; NSScanner * scanner = [NSScanner scannerWithString:string]; NSString * scannerResult; [scanner setCharactersToBeSkipped:nil]...

How to detect if certain characters are at the end of an NSString?

Let's assume I can have the following strings: "hey @john..." "@john, hello" "@john(hello)" I am tokenizing the string to get every word separated by a space: [myString componentsSeparatedByString:@" "]; My array of tokens now contain: @john... @john, @john(hello) I am checking for punctation marks as follows: NSRange textRange...

Replicating Mail Contact "Bubble" in iPhone SDK

Hi Everyone: When creating a new message using Mail on the iPhone, and after typing the contact, a blue "bubble" appears around the text. Is there some way I can replicate this behavior in my own application? Thanks for any help! ...

NSString - Unicode to ASCII equivalent

Hello, I need to convert NSString in unicode to NSString in ASCII changing all local characters: Ą to A, Ś to S, Ó to O, ü to u, And do on... What is the simplest way to do it? ...

String comparison in Objective-C

Hey, I've currently got a webserver set up which I communicate over SOAP with my iPhone app. I am returning a string containing a GUID and when I attempt to compare this with another string I get some strange results: Why would this not fire? Surely the two strings are a match? Thanks ...

string or nsstring with string

Lets assume myProp is @property (retain) NSString * myProp and synthesized for us.... self.myProp = @"some value";//string literal? self.myProp = [NSString stringWithString:@"some value"]; Is there a difference here? Is the first one a string literal that doesnt get autoreleased or is it just in memory for it's current scope and I d...

iPhone SDK Programming - Working with a variable across 2 views

I have what I hope is a fairly simple question about using the value from a variable across 2 views. I’m new to the iPhone SDK platform and the Model/View/Controller methodology. I’ve got background in VB.Net, some Php, but mostly SQL, so this is new ground for me. I’m building an app that has 3 views. For simplicity’s sake, I’ll call t...

iPhone dev: Replace uppercase characters in NSString with space and downcase

I have: NSString *promise = @"thereAreOtherWorldsThanThese"; which I'm trying to transform into the string: @"There are other worlds than these" I'm guessing this is a regex job, but I'm very new to Objective C, and have so far had no luck. I would greatly appreciate any help! ...