orthehelper
orthehelper

Reputation: 4079

How to replace a single char by index

i have a date string looks like this : 8/30/1987 at this time i can find the index of "/" by scan code. i want to replace the "/" character with "-". how can i do it?

TNX

Upvotes: 0

Views: 142

Answers (2)

PengOne
PengOne

Reputation: 48398

In general, reading the NSString documentation will answer questions like this.

For this, you can use the NSString method – stringByReplacingOccurrencesOfString:withString:

Upvotes: 2

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181460

Assuming you have your date on a NSString object, you can do:

NSString *new = [yourDate stringByReplacingOccurrencesOfString: @"/" withString:@"-"];

Upvotes: 1

Related Questions