There are 3 methods to substring a NSString.
NSLog([@"1234567890" substringFromIndex:4]); NSLog([@"1234567890" substringToIndex:6]); NSLog([@"1234567890" substringWithRange:NSMakeRange(3, 5)]);
Result
2010-07-15 12:39:43.712 Test[29478:20b] 567890 2010-07-15 12:39:43.716 Test[29478:20b] 123456 2010-07-15 12:39:43.719 Test[29478:20b] 45678
Done =)
Reference: NSRange and NSString Objects
Thanks that helped !
LikeLike
you are welcome. =)
LikeLike
nice help !
LikeLike
=)
LikeLike
Great! Just what I needed!
LikeLike
thanks for your comment. =D
LikeLike
thanks for this article 🙂
LikeLike
you are welcome =D
LikeLike
Very useful and helpful, thanks !
LikeLike
Good to know that i can help. =)
LikeLike
Short and to the point!
Thanks
LikeLike
Thanks for your comment. =)
LikeLike
you should choose a different theme than wordpress 2010, maybe journalcruch
LikeLike
thanks for your comment. i am using the hosting by wordpress.com and the journalcruch theme is not available. =P
LikeLike
Thanks 🙂
LikeLike
you are welcome.
=D
LikeLike
is there a way to use this with character and not integer
NSLog([@”1234567890″ substringWithRange:NSMakeRange(@”string”>”, @””)]);
ex: zfczf will become
zfczf
LikeLike
NSLog([message substringWithRange:NSMakeRange(@”string”>”, @””)]);
sorry it will be something like that 😀
LikeLike
I think you have to get the character position first and put it as the input parameters of NSMakeRange. The following example might help.
Easy NSString substring
LikeLike
That helped a lot! Thanks!!
LikeLike
Glad to know that it helps! =)
LikeLike