Top of the page
Close

This is a red error

This is a red error

This is a red error

How to remove first characters from string in iPhone SDK

Ondrej Rafaj on 2010.03.11 15:05:32

Removing first ore more characters from NSString in XCode (Objective-C; iPhone SDK)
NSString *str = @"Quick brown fox jumped over lazy dog";
NSString *newStr = [str substringWithRange:NSMakeRange(6, [str length] - 6)];

// or you can use

NSString *str = @"Quick brown fox jumped over lazy dog";
NSString *newStr = [str substringFromIndex:6];

// in both cases you'll get "brown fox jumped over lazy dog"
NSLog(@"New string: %@", newStr);


Ondrej Rafaj

Ondrej Rafaj

Independent iPhone developer @ ondrej-rafaj.co.uk

I am available to give you a free quote or start working on your project ... just give me a call or drop a line. Please find all my details on my portfolio site ondrej-rafaj.co.uk

Back to top Comment

Comments ... Why not to get involved!

We had to disable comments till the problem with spam will be solved, sorry for any inconvenience caused.

Back to top

IE SUCKS, DON'T USE IT :) Digg this page