user1641682
user1641682

Reputation:

'Trimming' an NSString

How do I 'trim' an NSString so that I can make a new string out of only a certain part of the old one?

For example is I have the string "Monday the 12th of September", how do I single out just the 'Monday' part?

Upvotes: 0

Views: 175

Answers (1)

Conor Taylor
Conor Taylor

Reputation: 3108

Using NSRange

Example:

NSRange range;
    range.location = 0;
    range.length = 6;
    NSString *Secondstring = [Firststring substringWithRange:dayRange];

Provided 'Firststring' contains "Monday the 12th of September", printing 'Secondstring' will give just 'Monday'

Upvotes: 1

Related Questions